chore: remove the hard coded artalk link for in favor the env.

This commit is contained in:
Yufan Sheng 2024-11-28 01:20:43 +08:00
parent cb95e90d97
commit 0fce8d770c
Signed by: syhily
GPG Key ID: DEB186763C308C31
3 changed files with 6 additions and 2 deletions

View File

@ -14,4 +14,6 @@ POSTGRES_PASSWORD=
POSTGRES_DATABASE=
# Artalk configuration
ARTALK_SCHEME=
ARTALK_HOST=
ARTALK_PORT=

View File

@ -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,
},

View File

@ -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<Comments | null> => {
let params: Record<string, string | number | boolean> = {