English | 简体中文
Usage
install plugin via pnpm/npm/yarn
pnpm add vitepress-plugin-rss
use in .vitepress/config.ts
add basic config
import { RSSOptions, RssPlugin } from 'vitepress-plugin-rss'
const baseUrl = 'https://sugarat.top'
const RSS: RSSOptions = {
title: '粥里有勺糖',
baseUrl,
copyright: 'Copyright (c) 2018-present, 粥里有勺糖',
}
export default defineConfig({
vite: {
plugins: [RssPlugin(RSS)]
}
})
then run build command,you can see generate feed.rss
log after rendering pages...
pnpm run build
the rss icon is also added to page nav socialLinks.
frontmatter
publish
Posts that publish: false
will not appear in the final rss file,can be used to ignore target articles
---
publish: false
---
Advanced Usage
Example
const RSS: RSSOptions = {
title: '粥里有勺糖',
baseUrl,
copyright: 'Copyright (c) 2018-present, 粥里有勺糖',
description: '大前端相关技术分享',
language: 'zh-cn',
author: {
name: '粥里有勺糖',
email: 'engineerzjl@foxmail.com',
link: 'https://sugarat.top'
},
icon: true,
authors: [
{
name: '粥里有勺糖',
email: 'engineerzjl@foxmail.com',
link: 'https://sugarat.top'
},
{
name: 'sugar',
email: '',
link: 'https://github.com/atqq'
}
],
filename: 'feed.rss',
log: true,
ignoreHome: true,
ignorePublish: false,
filter: (post, idx) => {
return true
}
}
Options
support all feed Options
plugin also defines some
here is the type definition
import type { Author, FeedOptions } from 'feed'
export type RSSOptions = Omit<FeedOptions, 'id'> & {
id?: string
filter?: (value: PostInfo, index: number, array: PostInfo[]) => boolean
baseUrl: string
url?: string
filename?: string
icon?: boolean | string
log?: boolean
ignoreHome?: boolean
ignorePublish?: boolean
authors?: Author[]
renderExpect?: (
fileContent: string,
frontmatter: Record<string, any>
) => string | Promise<string>
limit?: number
renderHTML?: ((filecontent: string) => string | Promise<string>) | boolean
locales?: Record<string, Omit<RSSOptions, 'locales'>>
}
FAQ
set response charset
Using Nginx as an example, you can add the following configuration
location ~ \.rss$ {
charset utf-8;
}
Thanks