Minimal Mistakes 主题教程:像 Post: Chat 示例一样写出对话体(聊天记录)博客帖
Minimal Mistakes 主题教程像 Post: Chat 示例一样写出对话体聊天记录博客帖【免费下载链接】minimal-mistakes:triangular_ruler: Jekyll theme for building a personal site, blog, project documentation, or portfolio.项目地址: https://gitcode.com/gh_mirrors/mi/minimal-mistakes导读本文围绕 Minimal Mistakes 文档站点中的Post: Chat示例帖docs/_posts/2010-01-08-post-chat.md完整讲解如何在 Minimal Mistakes 主题下创建对话体 / 聊天记录类型的 Jekyll 帖子从文件命名、Front Matter 编写、对话正文排版到single布局、分类与标签归档等底层渲染机制。读完本文你将掌握一套可直接复制的对话体帖子写作模板并能理解它在主题内部的渲染链路方便你迁移到自己的站点。一、Chat 帖子在 Minimal Mistakes 中的定位Minimal Mistakes 的文档站点维护着一个名为Post Formats帖子格式的示例系列用于演示同一套主题体系下不同类型正文的写法。除了本文主角Post: Chat外同系列还包含Post: Standard —— 标准图文混排帖Post: Modified —— 带修改时间戳的帖子Post: Quote —— 引用体帖子Post: Link —— 外链型帖子Post: Notice —— 使用提示框的帖子Post: Video (YouTube)、Post: Gallery 以及多篇图片对齐示例等其中Post: Chat承担的是对话 / 聊天记录这一种内容形态的演示正文完全由说话人 冒号 发言内容的纯文本段落组成不借助任何 Markdown 列表或引用语法因此它是验证纯文本段落渲染与Front Matter 驱动分类归档的极简范例。从源码结构看这类帖子与普通帖子没有任何特殊字段要求——它复用主题的标准文章管线single 布局这正是格式Format一词的含义内容形态不同渲染机制相同。二、创建 Chat 帖子的三步操作2.1 文件命名与存放位置与所有 Jekyll 帖子一样Chat 帖子存放在_posts目录下文件名遵循YEAR-MONTH-DAY-title.MARKUP规范见 docs/_docs/11-posts.md2016-07-20-writing-jekyll-posts.md 2015-01-03-static-site-generators.markdownYEAR为四位数字MONTH与DAY为两位数字MARKUP为内容格式扩展名主题在 docs/_config.yml 的markdown_ext中声明支持markdown,mkdown,mkdn,mkd,md。示例文件名为2010-01-08-post-chat.md即 2010 年 1 月 8 日发布的帖子。文件名中的日期会作为帖子的发布日期被 Jekyll 解析并用于归档排序。2.2 Front Matter用分类与标签给对话帖打标Post: Chat的 Front Matter 非常精简只有三组键值--- title: Post: Chat categories: - Post Formats tags: - chat - Post Formats ---title页面主标题渲染时显示为single布局的h1见 _layouts/single.html 第 34-38 行categories帖子分类此处为Post Formats用于聚合同系列示例tags帖子标签此处为chat与Post Formats用于更细粒度的检索。在主题的默认配置中docs/_config.yml 的defaults段所有type: posts的文档会自动获得layout: single、author_profile: true、read_time: true、comments: true、share: true、related: true所以 Chat 帖子无需在 Front Matter 里重复声明这些项即可享受作者资料、阅读时间、评论、社交分享与相关文章等完整能力。你只需关注title/categories/tags以及正文本身。分类和标签会在渲染时被 _includes/page__taxonomy.html 读取只要site.tag_archive.type与page.tags[0]存在就输出标签列表只要site.category_archive.type与page.categories[0]存在就输出分类列表。docs 站点的归档配置为category_archive: type: liquid path: /categories/ tag_archive: type: liquid path: /tags/即使用 Liquid 方式生成分类/标签归档页这意味着Post Formats分类与chat标签会自动出现在帖子的页脚元信息区并链接到对应归档。2.3 正文说话人冒号体Chat 帖子的正文写作规范极简单每一段以说话人姓名 英文冒号 空格开头之后是发言内容段与段之间用空行分隔。示例中两位说话人Abbott与Costello交替发言形成一问一答的节奏Abbott: Strange as it may seem, they give ball players nowadays very peculiar names. Costello: Funny names? Abbott: Nicknames, nicknames. Now, on the St. Louis team we have Whos on first, Whats on second, I Dont Know is on third--主题的 Markdown 引擎为 kramdowninput: GFM见 docs/_config.yml默认hard_wrap: false因此每个段落会自然渲染为p标签段内换行不会强制换行。这种写法不需要列表、引用块或代码块等任何特殊语法是最接近逐字稿的排版方式。提示如果你希望说话人名称在视觉上更突出也可以在此基础上扩展为 Markdown 段落加粗如**Abbott:** ...主题会将其渲染为加粗文本但保持纯文本段落是让对话内容在 RSS、全文搜索与无障碍阅读下最稳定的做法。三、完整示例Post: Chat 全文以下是Post: Chat的完整正文一段关于棒球队球员姓名的经典双人对话段子即广为流传的Whos on first。它演示了对话体帖子在真实篇幅下的排版效果——每句独立成段发言人标签清晰可辨Abbott: Strange as it may seem, they give ball players nowadays very peculiar names.Costello: Funny names?Abbott: Nicknames, nicknames. Now, on the St. Louis team we have Whos on first, Whats on second, I Dont Know is on third--Costello: Thats what I want to find out. I want you to tell me the names of the fellows on the St. Louis team.Abbott: Im telling you. Whos on first, Whats on second, I Dont Know is on third--Costello: You know the fellows names?Abbott: Yes.Costello: Well, then whos playing first?Abbott: Yes.Costello: I mean the fellows name on first base.Abbott: Who.Costello: The fellow playin first base.Abbott: Who.Costello: The guy on first base.Abbott: Who is on first.Costello: Well, what are you askin me for?Abbott: Im not asking you--Im telling you. Who is on first.Costello: Im asking you--whos on first?Abbott: Thats the mans name.Costello: Thats whos name?Abbott: Yes.Costello: When you pay off the first baseman every month, who gets the money?Abbott: Every dollar of it. And why not, the mans entitled to it.Costello: Who is?Abbott: Yes.Costello: So who gets it?Abbott: Why shouldnt he? Sometimes his wife comes down and collects it.Costello: Whos wife?Abbott: Yes. After all, the man earns it.Costello: Who does?Abbott: Absolutely.Costello: Well, all Im trying to find out is whats the guys name on first base?Abbott: Oh, no, no. What is on second base.Costello: Im not asking you whos on second.Abbott: Whos on first!Costello: St. Louis has a good outfield?Abbott: Oh, absolutely.Costello: The left fielders name?Abbott: Why.Costello: I dont know, I just thought Id ask.Abbott: Well, I just thought Id tell you.Costello: Then tell me whos playing left field?Abbott: Whos playing first.Costello: Stay out of the infield! The left fielders name?Abbott: Why.Costello: Because.Abbott: Oh, hes center field.Costello: Wait a minute. You got a pitcher on this team?Abbott: Wouldnt this be a fine team without a pitcher?Costello: Tell me the pitchers name.Abbott: Tomorrow.Costello: Now, when the guy at bat bunts the ball--me being a good catcher--I want to throw the guy out at first base, so I pick up the ball and throw it to who?Abbott: Now, thats he first thing youve said right.Costello: I DONT EVEN KNOW WHAT IM TALKING ABOUT!Abbott: Dont get excited. Take it easy.Costello: I throw the ball to first base, whoever it is grabs the ball, so the guy runs to second. Who picks up the ball and throws it to what. What throws it to I dont know. I dont know throws it back to tomorrow--a triple play.Abbott: Yeah, it could be.Costello: Another guy gets up and its a long ball to center.Abbott: Because.Costello: Why? I dont know. And I dont care.Abbott: What was that?Costello: I said, I DONT CARE!Abbott: Oh, thats our shortstop!这段对话刻意大量使用同音词Who / What / I Dont Know / Why / Because / Tomorrow 同时是疑问词与球员姓名很适合检验正文渲染时标点、破折号与全大写语句I DONT EVEN KNOW WHAT IM TALKING ABOUT!的处理效果。四、渲染链路Chat 帖子是如何变成页面的一个 Chat 帖子从 Markdown 到最终 HTML 页面走的是 Minimal Mistakes 标准的文章渲染管线布局解析由于_posts默认layout: singleJekyll 会使用 _layouts/single.html 渲染该帖子。该布局先判断是否需要页头page.header.*、面包屑site.breadcrumbs随后进入#main主体区。元信息输出single.html 第 26-29 行会把page.title、page.excerpt、page.date、page.last_modified_at写入 Schema.org 的itemprop元数据page__meta.html负责渲染发布日期与阅读时间阅读速度按 docs/_config.yml 的words_per_minute: 200估算。Chat 帖正文为纯文本字数统计准确、阅读时间稳定。正文与页脚正文经 kramdown 转为 HTML 后输出于page__content页脚page__meta中_includes/page__taxonomy.html 根据categories与tags生成归档链接对应category_archive.path: /categories/与tag_archive.path: /tags/。附加模块若page.share为真则渲染社交分享链接若page.related为真则渲染相关文章区评论仅在jekyll.environment production且配置了评论 provider 时输出见 single.html 第 69-78 行。因此即使正文只是对话文本Chat 帖子依然完整具备日期、分类、标签、分享、相关文章等全套主题能力无需额外开发任何插件。五、对话体帖子的适用场景与写作建议5.1 适用场景访谈 / 问答实录将采访稿整理为逐字稿直接按受访人: 发言的格式分段客服 / 故障排查记录复现用户报障 → 排查 → 解决的对话过程便于读者按时间线理解产品讨论纪要记录多人技术讨论让结论与论据的对应关系一目了然幽默 / 文学创作如本示例的Whos on first段子用对话制造笑点。5.2 写作建议说话人标签保持统一同一帖子内用相同的姓名或昵称写法如Abbott:与Costello:避免大小写、全半角冒号混用影响检索一致性善用excerpt如 docs/_docs/11-posts.md 的 ProTip 所述为每篇帖子编写独特的excerpt描述有助于 SEO 与归档列表展示。Chat 帖可在 Front Matter 中加入excerpt: 一段关于棒球队球员姓名的经典双人对话段子之类的一句话摘要利用分类与标签做聚合把同一系列对话帖放进同一个categories如Post Formats读者即可通过归档页浏览整个系列对话较长时控制段落粒度每句发言独立成段最清晰如果一段发言包含多个语义层次可在段内用破折号衔接如示例中的--用法。六、迁移到自己的站点要在自己的 Minimal Mistakes 站点发布对话体帖子只需在_posts目录下创建YEAR-MONTH-DAY-你的标题.md文件在 Front Matter 中声明title、categories、tags可选excerpt按说话人: 发言的段落格式书写正文参照 docs/_config.yml 的defaults段为type: posts配置layout: single及可选功能项然后jekyll serve本地预览。若站点使用 Gem 形式安装主题也可以直接对照仓库中的示例文件 docs/_posts/2010-01-08-post-chat.md 与配套的 docs/_docs/11-posts.md 文档快速确认命名、Front Matter 与渲染约定后再动手。【免费下载链接】minimal-mistakes:triangular_ruler: Jekyll theme for building a personal site, blog, project documentation, or portfolio.项目地址: https://gitcode.com/gh_mirrors/mi/minimal-mistakes创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考