From 0fce8d770c26f72db5f4800eaaaf4c3050dc4112 Mon Sep 17 00:00:00 2001 From: Yufan Sheng Date: Thu, 28 Nov 2024 01:20:43 +0800 Subject: [PATCH] chore: remove the hard coded artalk link for in favor the env. --- .env.example | 2 ++ astro.config.ts | 2 ++ src/components/comment/artalk.ts | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index b2446e9..3a9346d 100644 --- a/.env.example +++ b/.env.example @@ -14,4 +14,6 @@ POSTGRES_PASSWORD= POSTGRES_DATABASE= # Artalk configuration +ARTALK_SCHEME= ARTALK_HOST= +ARTALK_PORT= diff --git a/astro.config.ts b/astro.config.ts index 6a75b72..07feac1 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -32,7 +32,9 @@ export default defineConfig({ POSTGRES_PASSWORD: envField.string({ context: 'server', access: 'secret' }), POSTGRES_DATABASE: envField.string({ context: 'server', access: 'secret' }), // Artalk Comment + ARTALK_SCHEME: envField.string({ context: 'server', access: 'secret' }), ARTALK_HOST: envField.string({ context: 'server', access: 'secret' }), + ARTALK_PORT: envField.number({ context: 'server', access: 'secret' }), }, validateSecrets: true, }, diff --git a/src/components/comment/artalk.ts b/src/components/comment/artalk.ts index c42d789..f4ccb3c 100644 --- a/src/components/comment/artalk.ts +++ b/src/components/comment/artalk.ts @@ -2,7 +2,7 @@ import type { Comment, CommentItem, CommentReq, CommentResp, Comments, ErrorResp import { queryUser } from '@/helpers/db/query'; import { urlJoin } from '@/helpers/tools'; import options from '@/options'; -import { ARTALK_HOST } from 'astro:env/server'; +import { ARTALK_HOST, ARTALK_PORT, ARTALK_SCHEME } from 'astro:env/server'; import _ from 'lodash'; import { marked } from 'marked'; import querystring from 'node:querystring'; @@ -10,7 +10,7 @@ import { ELEMENT_NODE, transform, walk } from 'ultrahtml'; import sanitize from 'ultrahtml/transformers/sanitize'; // Access the artalk in internal docker host when it was deployed on zeabur. -const server = options.isProd() ? `http://${ARTALK_HOST}:23366` : `https://${ARTALK_HOST}`; +const server = `${ARTALK_SCHEME}://${ARTALK_HOST}:${ARTALK_PORT}`; export const loadComments = async (key: string, title: string | null, offset: number): Promise => { let params: Record = {