--- import type { CollectionEntry } from "astro:content"; import { commentConfig } from "@/config/commentConfig"; import Key from "@/i18n/i18nKey"; import { i18n } from "@/i18n/translation"; import { removeFileExtension } from "@/utils/url-utils"; import Artalk from "./Artalk.astro"; import Disqus from "./Disqus.astro"; import Giscus from "./Giscus.astro"; import Twikoo from "./Twikoo.astro"; import Waline from "./Waline.astro"; interface Props { post: CollectionEntry<"posts"> | CollectionEntry<"spec">; customPath?: string; } const { post, customPath } = Astro.props; const { id } = post; // 根据页面类型确定路径 const slug = removeFileExtension(id); const path = customPath || (post.collection === "posts" ? `/posts/${slug}` : `/${slug}`); const url = `${Astro.site?.href}${path}`; // 强制commentService类型为string,避免类型不兼容警告 let commentService: string = commentConfig?.type || "none"; --- { commentService !== "none" && (