update remark link to env

This commit is contained in:
ClovertaTheTrilobita 2026-04-04 20:57:22 +03:00
parent 3f23b930d3
commit 978ae2f363
4 changed files with 35 additions and 32 deletions

View file

@ -1,6 +1,2 @@
GITHUB_TOKEN= PUBLIC_REMARK42_HOST=https://comments.cloverta.top
GISCUS_REPO_OWNER= PUBLIC_REMARK42_SITE_ID=cloverta-blog
GISCUS_REPO_NAME=
GISCUS_CATEGORY_ID=
GISCUS_DATA_REPO_ID=
PUBLIC_COMMENT_SERVER_URL=

View file

@ -1,30 +1,38 @@
<script> <script>
export let url; import { onMount } from "svelte";
</script>
<svelte:head> export let url;
<script async lang="javascript">
var remark_config = { const host = import.meta.env.PUBLIC_REMARK42_HOST;
host: "https://comments.cloverta.top", const siteId = import.meta.env.PUBLIC_REMARK42_SITE_ID;
site_id: "cloverta-blog",
onMount(() => {
const remark_config = {
host,
site_id: siteId,
components: ["counter"], components: ["counter"],
show_rss_subscription: false, show_rss_subscription: false,
theme: localStorage.getItem("color-theme") ?? "light", theme: localStorage.getItem("color-theme") ?? "light",
}; };
!(function (e, n) {
for (var o = 0; o < e.length; o++) { window.remark_config = remark_config;
var r = n.createElement("script"),
c = ".js", for (const name of remark_config.components || ["embed"]) {
d = n.head || n.body; const script = document.createElement("script");
"noModule" in r let ext = ".js";
? ((r.type = "module"), (c = ".mjs"))
: (r.async = !0), if ("noModule" in script) {
(r.defer = !0), script.type = "module";
(r.src = remark_config.host + "/web/" + e[o] + c), ext = ".mjs";
d.appendChild(r); } else {
script.async = true;
} }
})(remark_config.components || ["embed"], document);
</script> script.defer = true;
</svelte:head> script.src = `${remark_config.host}/web/${name}${ext}`;
document.head.appendChild(script);
}
});
</script>
<span class="remark42__counter" data-url={url}></span> <span class="remark42__counter" data-url={url}></span>

View file

@ -23,8 +23,8 @@
const scriptId = "remark42-script"; const scriptId = "remark42-script";
window.remark_config = { window.remark_config = {
host: "https://comments.cloverta.top", host: import.meta.env.PUBLIC_REMARK42_HOST,
site_id: "cloverta-blog", site_id: import.meta.env.PUBLIC_REMARK42_SITE_ID,
components: ["embed"], components: ["embed"],
show_rss_subscription: false, show_rss_subscription: false,
theme: getTheme(), theme: getTheme(),

View file

@ -13,7 +13,6 @@
const href = link.getAttribute("href"); const href = link.getAttribute("href");
if (!href) return; if (!href) return;
// 只改 /posts/... 这种相对路径
if (href.startsWith("/posts/")) { if (href.startsWith("/posts/")) {
link.setAttribute("href", `/${lang}${href}`); link.setAttribute("href", `/${lang}${href}`);
} }
@ -22,8 +21,8 @@
onMount(() => { onMount(() => {
window.remark_config = { window.remark_config = {
host: "https://comments.cloverta.top", host: import.meta.env.PUBLIC_REMARK42_HOST,
site_id: "cloverta-blog", site_id: import.meta.env.PUBLIC_REMARK42_SITE_ID,
components: ["last-comments"], components: ["last-comments"],
theme: localStorage.getItem("color-theme") ?? "light", theme: localStorage.getItem("color-theme") ?? "light",
max_last_comments: 10, max_last_comments: 10,