Docusaurus 博客支持
· 2 min read
Docusaurus 使用 @docusaurus/plugin-content-blog 插件提供博客功能,classic 预设包含此插件,无须手动安装。
首先需要添加作者和文章的标签信息,用于在每篇博客的 Front Matter 中使用。 添加全局作者信息
autherKey:键名,用于在博客的 Front Matter 引用作者name:姓名title:职位/头衔url:个人网址social:社交账号githubx
website/blog/authors.yml
jmarcey:
name: Joel Marcey
title: Co-creator of Docusaurus 1
url: https://github.com/JoelMarcey
image_url: https://github.com/JoelMarcey.png
email: jimarcey@gmail.com
socials:
x: joelmarcey
github: JoelMarcey
slorber:
name: Sébastien Lorber
title: Docusaurus maintainer
url: https://sebastienlorber.com
image_url: https://github.com/slorber.png
socials:
x: sebastienlorber
github: slorber
email: seb@example.com
添加全局标签文件
blog/tags.yml
releases:
label: 'Product releases'
permalink: '/product-releases'
description: 'Content related to product releases.'
# A partial tag definition is also valid
announcements:
label: 'Announcements'
# An empty tag definition is also valid
# Other attributes will be inferred from the key
emptyTag:
博客的 Front Matter,可以引用上面定义的作者和标签
---
title: Welcome Docusaurus
authors:
- slorber
- yangshun
- name: Joel Marcey
title: Co-creator of Docusaurus 1
url: https://github.com/JoelMarcey
image_url: https://github.com/JoelMarcey.png
socials:
x: joelmarcey
github: JoelMarcey
tags: [docusaurus]
description: This is my first post on Docusaurus.
image: https://i.imgur.com/mErPwqL.png
hide_table_of_contents: false
---
A Markdown blog post
博客列表页可以控制要显示的内容摘要,在文章中使用 <!--truncate--> 标记内容摘要,标记以上的内容将成为摘要
website/blog/my-post.md
---
title: Markdown blog truncation example
---
All these will be part of the blog post summary.
<!-- truncate -->
But anything from here on down will not be.
note
mdx 使用 {/* truncate */}