← 指南与示例
Terminal window
src/utils/theme.ts
1111 字
6 分钟
Shirone 创作与使用指南

欢迎使用 Shirone(白音)——一款富有表现力、充满动漫风格的博客主题,基于 Astro 7、Svelte 5 和 Material 3 Expressive(M3E) 设计系统打造。
本指南将带你了解文章创建、frontmatter 规范、目录结构,以及完整的内置 Markdown 和 MDX 扩展。
1. 创建新文章
你可以使用内置 CLI 命令,快速创建一篇带有标准 frontmatter 的新文章:
# 创建单文件文章pnpm new-post my-first-post
# 或在子目录中创建文章pnpm new-post guides/getting-started新建的文件会放在 src/content/posts/ 中。
2. Frontmatter 规范
每篇 Markdown(.md)或 MDX(.mdx)文章都以 YAML frontmatter 块开头,用于定义文章元数据。
示例
---title: "探索 Material 3 Expressive 设计"published: 2026-08-26updated: 2026-08-27publishedAt: 2026-08-26T10:00:00+08:00updatedAt: 2026-08-27T09:30:00+08:00pinned: truedescription: "了解 Shirone 中的 HCT 动态配色与流畅过渡。"image: "./cover.webp"tags: [M3E, 设计, 前端]category: 指南draft: falsecomment: true---支持的 Frontmatter 字段
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
title | string | 是 | 文章主标题。 |
published | Date | 是 | YYYY-MM-DD 格式的发布日期。 |
publishedAt | Date | 否 | 精确发布时间,用于排列同一天发布的文章。它必须落在站点所配置时区下的 published 当天。 |
updated | Date | 否 | 最后更新日期。填写后会显示更新提示徽章。 |
updatedAt | Date | 否 | 供订阅源和机器可读元数据使用的精确更新时间,必须与 updated 一同填写。 |
pinned | boolean | 否 | 将文章固定在文章列表顶部(默认值:false)。 |
description | string | 否 | 显示在文章卡片、搜索结果和 OpenGraph 元数据中的文章摘要。 |
image | string | 否 | 封面图片路径。支持相对路径(./cover.webp)、公共路径(/images/cover.jpg)或远程 URL。 |
tags | string[] | 否 | 用于分类筛选和标签云的标签名称数组。 |
category | string | 否 | 用于分类索引的主要分类名称。 |
draft | boolean | 否 | 标记为草稿。执行生产构建(pnpm build)时不会显示草稿文章。 |
comment | boolean | 否 | 控制当前文章是否显示评论区(默认值:true)。 |
lang | string | 否 | 文章语言与站点默认语言不同时填写的语言代码(例如 en、zh_CN、ja)。 |
3. 文章加密
Shirone 提供客户端文章加密功能。对于私人日记或限制访问的文章,请在 frontmatter 中指定密码:
---title: "私人研究笔记"published: 2026-08-26encrypted: truepassword: "你的密码"passwordHint: "我最喜欢的动画角色"hideHomeContent: true---encrypted:设为true以启用加密;password:解锁文章所需的密码字符串或数字;passwordHint:显示在密码输入表单上方的可选提示;hideHomeContent:在首页隐藏字数统计和内容预览,防止数据泄露。
4. 整理文章文件
Shirone 同时支持按文件夹集中存放资源和单文件两种组织方式:
文件夹结构(推荐用于本地资源)
将文章与相关媒体文件放在一起,可以更方便地管理资源:
src/content/posts/├── my-great-post/│ ├── index.md <-- 文章正文│ ├── cover.webp <-- 封面图片(image: "./cover.webp")│ └── diagram.png <-- 正文引用的插图单文件结构(适合轻量文本)
src/content/posts/├── hello-world.md└── quick-thoughts.md5. 丰富的 Markdown 与 MDX 扩展
Shirone 开箱即用地提供了现代 Markdown 扩展:
5.1 提示容器
使用容器指令展示备注、提示、警告和重要提醒:
:::tipUse admonition containers to highlight key takeaways or best practices.:::
:::warningUse warning containers to signal potential pitfalls or breaking changes.:::5.2 GitHub 仓库卡片
使用指令语法嵌入实时更新、样式精美的 GitHub 仓库卡片:
::github{repo="LyraVoid/Shirone"}5.3 Expressive Code 代码块
增强代码块支持语法高亮、文件名徽章、行号和指定行高亮:
// Dynamic HCT color token derivationimport { argbFromHex, themeFromSourceColor } from "@material/material-color-utilities";
const theme = themeFromSourceColor(argbFromHex("#f472b6"));console.log("Primary color token:", theme.schemes.light.primary);5.4 数学公式排版(KaTeX)
直接在 Markdown 中渲染优雅的 LaTeX 数学公式:
- 行内公式:,或欧拉公式 。
- 块级公式:
5.5 Mermaid 图表
使用纯文本创建流程图、时序图和架构图:
sequenceDiagram
autonumber
actor Visitor as Visitor
participant Page as Shirone Page
participant Swup as Swup Container
participant Audio as Persistent Shell
Visitor->>Page: Click Navigation Link
Page->>Swup: Trigger Seamless Transition
Swup->>Page: Replace #swup-container
Note over Audio: Background music plays continuously
Page-->>Visitor: New Page Rendered5.6 图片画廊与 Fancybox 灯箱
图片会自动集成 Fancybox,支持无损缩放、平移手势和全屏预览:
6. 后续步骤与自定义
- 站点配置:在
src/config/siteConfig.ts和src/config/README.md中了解全局设置。 - 设计令牌:在
DESIGN.md和docs/m3e-standard.md中探索设计令牌与配色方案。 - 反馈与社区:前往 GitHub Issues 分享你的想法和问题。
Shirone 创作与使用指南
https://blog.datahuk.top/posts/guide/分享文章
生成精美分享图或复制链接,与更多人分享本文。
最后更新于 ,距今已过 90 天
部分内容可能已过时