diff --git a/src/config.ts b/src/config.ts index 2c0f489..28ab569 100644 --- a/src/config.ts +++ b/src/config.ts @@ -65,7 +65,7 @@ export const navBarConfig: NavBarConfig = { }, { name: "统计信息", - url: "https://umami.adclosenn.top/share/XMDJoIb1D21UxHdH", // Internal links should not include the base path, as it is automatically added + url: "https://umami.adclosenn.top/share/jME4HFb9JmfJM5zs", // Internal links should not include the base path, as it is automatically added external: true, // Show an external link icon and will open in a new tab }, { @@ -128,6 +128,6 @@ export const expressiveCodeConfig: ExpressiveCodeConfig = { export const umamiConfig: UmamiConfig = { enable: true, baseUrl: "https://umami.adclosenn.top", - shareId: "XMDJoIb1D21UxHdH", + shareId: "jME4HFb9JmfJM5zs", timezone: "Asia/Shanghai", }; \ No newline at end of file diff --git a/src/content/assets/images/cloudflare-turnstile-verify-error-1.png b/src/content/assets/images/cloudflare-turnstile-verify-error-1.png new file mode 100644 index 0000000..492ef1b Binary files /dev/null and b/src/content/assets/images/cloudflare-turnstile-verify-error-1.png differ diff --git a/src/content/assets/images/cloudflare-turnstile-verify-error.png b/src/content/assets/images/cloudflare-turnstile-verify-error.png new file mode 100644 index 0000000..dbc44f4 Binary files /dev/null and b/src/content/assets/images/cloudflare-turnstile-verify-error.png differ diff --git a/src/content/assets/images/custom-frontmatter-cover.svg b/src/content/assets/images/custom-frontmatter-cover.svg new file mode 100644 index 0000000..668bc73 --- /dev/null +++ b/src/content/assets/images/custom-frontmatter-cover.svg @@ -0,0 +1,17 @@ +
\ No newline at end of file diff --git a/src/content/assets/images/custom-frontmatter-customcover.svg b/src/content/assets/images/custom-frontmatter-customcover.svg new file mode 100644 index 0000000..1d5bbe2 --- /dev/null +++ b/src/content/assets/images/custom-frontmatter-customcover.svg @@ -0,0 +1,17 @@ +
\ No newline at end of file diff --git a/src/content/assets/images/frontmatter-image-example.png b/src/content/assets/images/frontmatter-image-example.png new file mode 100644 index 0000000..7505f3a Binary files /dev/null and b/src/content/assets/images/frontmatter-image-example.png differ diff --git a/src/content/config.ts b/src/content/config.ts index 6ce4b4e..9fc6723 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -10,6 +10,9 @@ const postsCollection = defineCollection({ image: z.string().optional().default(""), tags: z.array(z.string()).optional().default([]), category: z.string().optional().nullable().default(""), + showcover: z.boolean().optional().default(true), + customcover: z.string().optional().default(""), + lang: z.string().optional().default(""), /* For internal use */ diff --git a/src/content/posts/captcha.md b/src/content/posts/captcha.md new file mode 100644 index 0000000..95e61bd --- /dev/null +++ b/src/content/posts/captcha.md @@ -0,0 +1,63 @@ +--- +title: "你是人类吗?" +published: 2025-08-12 +tags: ["验证"] +description: 我的 Captcha 还蛮多的,欢迎你们来这里玩,玩累了就直接刷新,没问题的~ +image: ../assets/images/cloudflare-turnstile-verify-error-1.png +category: 杂项 +draft: false +showcover: false +customcover: ../assets/images/cloudflare-turnstile-verify-error.png +--- + + + + + + + + + + + +你好~ +我的 Captcha 还蛮多的,欢迎你们来这里玩,玩累了就直接刷新,没问题的~ + +:::NOTE["抱歉"] +现在只有两家 Captcha,后续会慢慢补上其他 Captcha 的! +::: + +# Google reCaptcha V2 +## 休闲版(不保证) + +
+
+
+ +## 挑战版(不保证) + +
+
+
+ +
+ +# Cloudflare Turnstile + +
+ + \ No newline at end of file diff --git a/src/content/posts/custom-frontmatter.md b/src/content/posts/custom-frontmatter.md new file mode 100644 index 0000000..79c52ac --- /dev/null +++ b/src/content/posts/custom-frontmatter.md @@ -0,0 +1,258 @@ +--- +title: "自定义 Astro 的 Frontmatter" +published: 2025-08-13 +tags: ["教程", "网站"] +description: 如果你想要在 Astro 的 Makdown Frontmatter 中自定义参数,布尔值或字符串,实现直接开关或更改某样组件,可以这样做 +image: "../assets/images/custom-frontmatter-cover.svg" +category: 教程 +showcover: false +customcover: ../assets/images/custom-frontmatter-customcover.svg +--- + +# 前言 +如果你用的博客是 [Astro](https://astro.build) 或以它为架构的 [Fuwari](https://github.com/saicaca/fuwari),那么这篇文章或许适合。 + +这篇文章的目的是 **在 Markdown 文件的顶端加入一个自定义的类似 `draft: true` 这类变量控制器**,可以运用它对某些组件进行更改,包括关闭、更改。例如,当你在 fuwari 中的 Markdown 顶端定义一个内置参数 `image`,你可以通过写 `image: "../assets/images/custom-frontmatter-cover.svg"` 来让这篇文章在**博客主页**获得一个图片(而不定义就只有一个 `>` 的按钮): ![frontmatter-image-example](../assets/images/frontmatter-image-example.png) + +如果你足够细心,你会发现文章 [你是人类吗?](/posts/captcha/) 的图片在**博客主页**和**文章内部**是不同的。这也用到了自定义 Frontmatter,自己定义了不同的地方该显示什么图片。 + +# 定义 Frontmatter +:::tip[提示] +如果你使用的也是 Astro Fuwari,那么这些操作理应是**相同**且**可用**的。 +::: + +打开 `src/content/config.ts` 文件,在 `const postsCollection = defineCollection({` 部分,参考已有的示例定义一个**不重名**的参数,以下是本站的: + +**boolen**:布尔值。可以通过 `true` 和 `false` 控制。 +**string**:字符串。填写的是一串文本。 + +最后面括号中的 `true` 指的是如果 Markdown 文件顶端的 Frontmatter 里**没有**这个参数,就默认为 `true`。`string` 也同理。 + +```ts title="src/content/config.ts" {11-12} +const postsCollection = defineCollection({ + schema: z.object({ + title: z.string(), + published: z.date(), + updated: z.date().optional(), + draft: z.boolean().optional().default(false), + description: z.string().optional().default(""), + image: z.string().optional().default(""), + tags: z.array(z.string()).optional().default([]), + category: z.string().optional().nullable().default(""), + showcover: z.boolean().optional().default(true), + customcover: z.string().optional().default(""), + + lang: z.string().optional().default(""), + + /* For internal use */ + prevTitle: z.string().default(""), + prevSlug: z.string().default(""), + nextTitle: z.string().default(""), + nextSlug: z.string().default(""), + }), +}); +``` + +# 配置 Frontmatter(样例) +## 关闭文章头图 +默认你使用 `image` 定义了一张图片,那么这张图片将会同时显示在**博客主页**和 **文章内部(那个大大的图片,位于文章之首)**。 +如不需要使用**博客主页**那张图片作为文章内部的照片,我们可以**关闭文章内部的头图显示,只剩下文章正文和文章的图片,而博客主页那个卡片右边的图片依然显示**。 + +打开 `src/pages/posts/[...slug].astro`,(这个可选:在**第二处** `---` 上面加入 `const 随便一个不重复名字 = entry.data.你在#定义 Frontmatter定义的参数。` ,本站是 `showcover = enrty.data.showcover;`) +找到 `{entry.data.image &&`,将其改为 `{entry.data.showcover && entry.data.image &&`。如图所示: + +:::warning[注意] +1. 如果你做了上面的可选步骤(定义了一个变量),那么可以将其改为 `{变量名 && entry.data.image &&`。 +2. 如果你**没有使用**在 [#定义 Frontmatter](#定义-frontmatter) 中的本站自定义的参数,这里就无法使用 entry.data.showcover。 +::: + +```astro title="src/pages/posts/[...slug.astro]" {1} + {entry.data.showcover && entry.data.image && +