mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-04-23 10:58:13 +08:00
feat(theme): add support for seo & sitemap plugin options (#351)
This commit is contained in:
parent
49c896b8ce
commit
f2f2730759
@ -19,6 +19,22 @@ export default defineUserConfig({
|
||||
})
|
||||
```
|
||||
|
||||
如需要自定义 SEO 优化,可以通过 `plugins.seo` 配置来实现。
|
||||
|
||||
```js
|
||||
export default defineUserConfig({
|
||||
theme: plumeTheme({
|
||||
plugins: {
|
||||
seo: {
|
||||
// ... seo 配置
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
完整配置请查看 [文档](https://ecosystem.vuejs.press/zh/plugins/seo/seo/config.html)
|
||||
|
||||
::: note
|
||||
示例 Fork 自 [@vuepress/plugin-seo](https://ecosystem.vuejs.press/zh/plugins/seo/seo/),
|
||||
遵循 [MIT](https://github.com/vuepress/ecosystem/blob/main/LICENSE) 许可证。
|
||||
|
||||
@ -18,3 +18,19 @@ export default defineUserConfig({
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
如需要自定义 sitemap,可以通过 `plugins.sitemap` 配置来实现。
|
||||
|
||||
```js
|
||||
export default defineUserConfig({
|
||||
theme: plumeTheme({
|
||||
plugins: {
|
||||
sitemap: {
|
||||
// ... sitemap 配置
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
完整配置请查看 [文档](https://ecosystem.vuejs.press/zh/plugins/seo/sitemap/config.html)
|
||||
|
||||
@ -11,8 +11,8 @@ import { markdownMathPlugin } from '@vuepress/plugin-markdown-math'
|
||||
import { nprogressPlugin } from '@vuepress/plugin-nprogress'
|
||||
import { photoSwipePlugin } from '@vuepress/plugin-photo-swipe'
|
||||
import { readingTimePlugin } from '@vuepress/plugin-reading-time'
|
||||
import { seoPlugin } from '@vuepress/plugin-seo'
|
||||
import { sitemapPlugin } from '@vuepress/plugin-sitemap'
|
||||
import { seoPlugin, type SeoPluginOptions } from '@vuepress/plugin-seo'
|
||||
import { sitemapPlugin, type SitemapPluginOptions } from '@vuepress/plugin-sitemap'
|
||||
import { watermarkPlugin } from '@vuepress/plugin-watermark'
|
||||
import { contentUpdatePlugin } from '@vuepress-plume/plugin-content-update'
|
||||
import { fontsPlugin } from '@vuepress-plume/plugin-fonts'
|
||||
@ -154,12 +154,19 @@ export function getPlugins(
|
||||
plugins.push(commentPlugin(pluginOptions.comment))
|
||||
}
|
||||
|
||||
if (pluginOptions.sitemap !== false && hostname && isProd) {
|
||||
plugins.push(sitemapPlugin({ hostname }))
|
||||
if (pluginOptions.sitemap !== false && isProd) {
|
||||
const sitemapOptions = isPlainObject(pluginOptions.sitemap) ? pluginOptions.sitemap : {}
|
||||
sitemapOptions.hostname ||= hostname
|
||||
|
||||
if (sitemapOptions.hostname)
|
||||
plugins.push(sitemapPlugin(sitemapOptions as SitemapPluginOptions))
|
||||
}
|
||||
|
||||
if (pluginOptions.seo !== false && hostname && isProd) {
|
||||
plugins.push(seoPlugin({ hostname }))
|
||||
const seoOptions = isPlainObject(pluginOptions.seo) ? pluginOptions.seo : {}
|
||||
seoOptions.hostname ||= hostname
|
||||
if (seoOptions.hostname)
|
||||
plugins.push(seoPlugin(seoOptions as SeoPluginOptions))
|
||||
}
|
||||
|
||||
if (cache !== false) {
|
||||
|
||||
@ -3,6 +3,8 @@ import type { DocSearchOptions } from '@vuepress/plugin-docsearch'
|
||||
import type { MarkdownImagePluginOptions } from '@vuepress/plugin-markdown-image'
|
||||
import type { MarkdownMathPluginOptions } from '@vuepress/plugin-markdown-math'
|
||||
import type { ReadingTimePluginOptions } from '@vuepress/plugin-reading-time'
|
||||
import type { SeoPluginOptions } from '@vuepress/plugin-seo'
|
||||
import type { SitemapPluginOptions } from '@vuepress/plugin-sitemap'
|
||||
import type { WatermarkPluginOptions } from '@vuepress/plugin-watermark'
|
||||
import type { SearchPluginOptions } from '@vuepress-plume/plugin-search'
|
||||
import type { ShikiPluginOptions } from '@vuepress-plume/plugin-shikiji'
|
||||
@ -69,9 +71,9 @@ export interface PlumeThemePluginOptions {
|
||||
|
||||
comment?: false | CommentPluginOptions
|
||||
|
||||
sitemap?: false
|
||||
sitemap?: false | Omit<SitemapPluginOptions, 'hostname'> & { hostname?: string }
|
||||
|
||||
seo?: false
|
||||
seo?: false | Omit<SeoPluginOptions, 'hostname'> & { hostname?: string }
|
||||
|
||||
/**
|
||||
* 阅读时间、字数统计
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user