Docusaurus二次魔改增加博客分类

摘要: Docusaurus二次魔改增加博客分类


增加博客分类

写在前面

使用方式

分类主页/blog/categories

在博客md文件开头增加如下代码

key支持categories或者category

value支持字符串, 数字,数组`

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
---
categories:
- 默认分类,一般用这个即可
---
或者
---
categories: 默认分类
---
或者
---
category:
- 默认分类
---
或者
---
category: 默认分类
---

魔改涉及文件

1
2
3
4
5
6
7
8
9
/src/plugin/plugin-content-blog/index.js 主要在这个类里修改 增加路由 构建数据
/src/plugin/plugin-content-blog/utils.js 一些工具方法

/src/components/BlogCategories/BlogCategoriesList.js 分类主页组件/blog/categories
/src/components/BlogCategories/BlogTagsPostsPage/* 改动不大,只改了显示
/src/components/BlogCategories/TagsListByLetter/* 改动不大 用默认主题带的build不过 只好拿过来

/src/theme/BlogPostItem/Footer/index.tsx 按分类查看博客列表页面展示分类/blog/categories/XXX
/src/theme/BlogPostItem/Header/Info/index.tsx 博客页面 增加展示分类

站点配置修改

  • 修改/data下数据
  • 修改/src/config.ts
  • 修改docusaurus.config.ts
  • sidebars.ts

增加禁止评论

1
2
3
4
5
6
7
8
9
10
11
12
本身支持
hide_comment: true

二次开发后 增加支持
comments: false ----------一般用这个就行了 hexo写法

comment:
enable: false ------------hugo next写法

comment: false ------------vuepress2 hope 写法