From ca4de9738d95281650324e528da88fc05aaa6e4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E4=BA=91=E8=8B=8D=E7=8B=97?= Date: Mon, 6 Nov 2023 16:41:41 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=83=20docs:=20=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/guide/config.md | 33 +++++++++++++++++++ .../vitepress-theme-async/config/index.js | 8 ++--- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/docs/guide/config.md b/docs/guide/config.md index 0a3ea00..385951a 100644 --- a/docs/guide/config.md +++ b/docs/guide/config.md @@ -506,6 +506,31 @@ interface ConverConfig { } ``` +### 过期提醒 NoticeOutdate + +通过配置 `noticeOutdate` 字段使用,`enable` 为 `true` 时,会根据文章发布时间计算已经过去多少天,如果超出 `limitDay` 配置天数,则会显示过期提醒标识 + +```ts +interface NoticeOutdateConfig { + /** + * 是否启用 + */ + enable?: boolean; + /** + * 样式 + */ + style?: "simple" | "flat"; + /** + * 距离今天多少天时显示 + */ + limitDay?: number; + /** + * 现实在文章中位置 + */ + position?: "top" | "bottom"; +} +``` + ## 友接页 Links 在 layout 为 `links` 时为友链页,页面会根据 `links` 配置渲染列表。 @@ -601,6 +626,14 @@ interface BuiltPageConfig { 具体插槽 [请看这里](https://github.com/maluns/vitepress-theme-async/packages/vitepress-theme-async/layouts/Layout.vue) +## 全局组件 Global Components + +主题中将页面中部分模块拆分单独的组件,位于 `vitepress-theme-async/components/global` 目录中。可通过 `globalComponents` 字段配置是否需要将组件注册为全局组件使用,设置为 `true` 默认会将所有组件注册为全局组件,也可一传递组件名称 `['TrmDividerTitle']` 选择性的注册。 + +```ts +globalComponents?: boolean | Array; +``` + ## 自定义图标 Icon 主题内置图标是通过组件方式使用的,参考 vitepress 覆盖组件使用方式。 diff --git a/packages/vitepress-theme-async/config/index.js b/packages/vitepress-theme-async/config/index.js index 14a3b26..3568122 100644 --- a/packages/vitepress-theme-async/config/index.js +++ b/packages/vitepress-theme-async/config/index.js @@ -171,11 +171,11 @@ export const defineConfig = config => { } // 处理 less 配置 - config.vite.css.preprocessorOptions.less.globalVars.isReadmode = Boolean(config.themeConfig.rightside.readmode); - config.vite.css.preprocessorOptions.less.globalVars.isAside = Boolean(config.themeConfig.rightside.aside); - config.vite.css.preprocessorOptions.less.globalVars.isReward = Boolean(config.themeConfig.reward.enable); + config.vite.css.preprocessorOptions.less.globalVars.isReadmode = Boolean(config.themeConfig?.rightside?.readmode); + config.vite.css.preprocessorOptions.less.globalVars.isAside = Boolean(config.themeConfig?.rightside?.aside); + config.vite.css.preprocessorOptions.less.globalVars.isReward = Boolean(config.themeConfig?.reward?.enable); config.vite.css.preprocessorOptions.less.globalVars.isSearch = Boolean(config.themeConfig?.search?.provider === 'local'); - config.vite.css.preprocessorOptions.less.globalVars.isCustomMdStyle = Boolean(config.themeConfig.customMdStyle); + config.vite.css.preprocessorOptions.less.globalVars.isCustomMdStyle = Boolean(config.themeConfig?.customMdStyle); return config; };