feat: hide the comments locally for avoiding the usage from the forkers.

This commit is contained in:
Yufan Sheng 2024-11-28 00:45:05 +08:00
parent bb8fdfbf9a
commit 7e5ea881db
Signed by: syhily
GPG Key ID: DEB186763C308C31
5 changed files with 4 additions and 6 deletions

View File

@ -67,7 +67,6 @@ const Options = z
calendar: z.boolean().default(false),
}),
comments: z.object({
server: z.string().url().readonly(),
size: z.number().default(10).readonly(),
avatar: z.object({
mirror: z.string().url().readonly(),
@ -191,7 +190,6 @@ const options: z.input<typeof Options> = {
calendar: true,
},
comments: {
server: 'https://comment.yufan.me',
size: 10,
avatar: {
mirror: 'https://weavatar.com/avatar',

View File

@ -11,7 +11,7 @@ interface Props {
}
const { commentKey, title } = Astro.props;
const comments = await loadComments(commentKey, title, 0);
const comments = options.isProd() ? await loadComments(commentKey, title, 0) : null;
// Increase the PV in production environment.
if (options.isProd()) {

View File

@ -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` : options.settings.comments.server;
const server = options.isProd() ? `http://${ARTALK_HOST}:23366` : 'http://localhost:23366';
export const loadComments = async (key: string, title: string | null, offset: number): Promise<Comments | null> => {
let params: Record<string, string | number | boolean> = {

View File

@ -30,7 +30,7 @@ const { Content, headings } = await page.render();
<TableOfContents {headings} toc={page.toc} />
<div class="post-content">
<div class="nc-light-gallery">
<Content components={{ MusicPlayer: MusicPlayer, Image: Image }} />
{page.comments && options.isProd() && <Content components={{ MusicPlayer: MusicPlayer, Image: Image }} />}
</div>
</div>
{page.friend && <Friends />}

View File

@ -66,7 +66,7 @@ const { Content, headings } = await post.render();
<LikeButton permalink={post.permalink} />
<LikeShare {post} />
{
post.comments && (
post.comments && options.isProd() && (
<Comments commentKey={urlJoin(options.website, post.permalink, '/')} title={post.title} />
)
}