diff --git a/docs/.vitepress/buildEnd.config.ts b/docs/.vitepress/buildEnd.config.ts new file mode 100644 index 000000000..b819e3acf --- /dev/null +++ b/docs/.vitepress/buildEnd.config.ts @@ -0,0 +1,49 @@ +import path from 'path' +import { writeFileSync } from 'fs' +import { Feed } from 'feed' +import { createContentLoader, type SiteConfig } from 'vitepress' + +const siteUrl = 'https://vitejs.dev' +const blogUrl = `${siteUrl}/blog` + +export const buildEnd = async (config: SiteConfig) => { + const feed = new Feed({ + title: 'Vite', + description: 'Next Generation Frontend Tooling', + id: blogUrl, + link: blogUrl, + language: 'en', + image: 'https://vitejs.dev/og-image.png', + favicon: 'https://vitejs.dev/logo.svg', + copyright: 'Copyright © 2019-present Evan You & Vite Contributors', + }) + + const posts = await createContentLoader('blog/*.md', { + excerpt: true, + render: true, + }).load() + + posts.sort( + (a, b) => + +new Date(b.frontmatter.date as string) - + +new Date(a.frontmatter.date as string), + ) + + for (const { url, excerpt, frontmatter, html } of posts) { + feed.addItem({ + title: frontmatter.title, + id: `${siteUrl}${url}`, + link: `${siteUrl}${url}`, + description: excerpt, + content: html, + author: [ + { + name: frontmatter.author.name, + }, + ], + date: frontmatter.date, + }) + } + + writeFileSync(path.join(config.outDir, 'blog.rss'), feed.rss2()) +} diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index b8b06ff22..d6506c4d8 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -1,4 +1,5 @@ import { defineConfig, DefaultTheme } from 'vitepress' +import { buildEnd } from './buildEnd.config' const ogDescription = 'Next Generation Frontend Tooling' const ogImage = 'https://vitejs.dev/og-image.png' @@ -66,6 +67,10 @@ export default defineConfig({ head: [ ['link', { rel: 'icon', type: 'image/svg+xml', href: '/logo.svg' }], + [ + 'link', + { rel: 'alternate', type: 'application/rss+xml', href: '/blog.rss' }, + ], ['meta', { property: 'og:type', content: 'website' }], ['meta', { property: 'og:title', content: ogTitle }], ['meta', { property: 'og:image', content: ogImage }], @@ -325,4 +330,5 @@ export default defineConfig({ level: [2, 3], }, }, + buildEnd, }) diff --git a/docs/blog/announcing-vite2.md b/docs/blog/announcing-vite2.md index e9f6da0ce..11cd6d523 100644 --- a/docs/blog/announcing-vite2.md +++ b/docs/blog/announcing-vite2.md @@ -1,4 +1,7 @@ --- +title: Announcing Vite 2.0 +author: + - name: The Vite Team sidebar: false date: 2021-02-16 head: diff --git a/docs/blog/announcing-vite3.md b/docs/blog/announcing-vite3.md index 8aaa4d01c..a5fe24ede 100644 --- a/docs/blog/announcing-vite3.md +++ b/docs/blog/announcing-vite3.md @@ -1,6 +1,9 @@ --- -sidebar: false +title: Vite 3.0 is out! +author: + name: The Vite Team date: 2022-07-23 +sidebar: false head: - - meta - property: og:type diff --git a/docs/blog/announcing-vite4-3.md b/docs/blog/announcing-vite4-3.md index 8ed3fdb38..534a2fdcb 100644 --- a/docs/blog/announcing-vite4-3.md +++ b/docs/blog/announcing-vite4-3.md @@ -1,6 +1,9 @@ --- -sidebar: false +title: Vite 4.3 is out! +author: + name: The Vite Team date: 2023-04-20 +sidebar: false head: - - meta - property: og:type diff --git a/docs/blog/announcing-vite4.md b/docs/blog/announcing-vite4.md index 3b3280b99..587d43973 100644 --- a/docs/blog/announcing-vite4.md +++ b/docs/blog/announcing-vite4.md @@ -1,6 +1,9 @@ --- -sidebar: false +title: Vite 4.0 is out! +author: + name: The Vite Team date: 2022-12-09 +sidebar: false head: - - meta - property: og:type diff --git a/docs/blog/announcing-vite5.md b/docs/blog/announcing-vite5.md index 02f360d18..1ce435792 100644 --- a/docs/blog/announcing-vite5.md +++ b/docs/blog/announcing-vite5.md @@ -1,6 +1,9 @@ --- -sidebar: false +title: Vite 5.0 is out! +author: + name: The Vite Team date: 2023-11-16 +sidebar: false head: - - meta - property: og:type diff --git a/package.json b/package.json index df29fcf22..bf7e3f178 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "eslint-plugin-n": "^16.3.1", "eslint-plugin-regexp": "^2.1.1", "execa": "^8.0.1", + "feed": "^4.2.2", "fs-extra": "^11.1.1", "lint-staged": "^15.1.0", "npm-run-all2": "^6.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index eb5d616f9..886679967 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -111,6 +111,9 @@ importers: execa: specifier: ^8.0.1 version: 8.0.1 + feed: + specifier: ^4.2.2 + version: 4.2.2 fs-extra: specifier: ^11.1.1 version: 11.1.1 @@ -6001,6 +6004,13 @@ packages: dependencies: reusify: 1.0.4 + /feed@4.2.2: + resolution: {integrity: sha512-u5/sxGfiMfZNtJ3OvQpXcvotFpYkL0n9u9mM2vkui2nGo8b4wvDkJ8gAkYqbA8QpGyFCv3RK0Z+Iv+9veCS9bQ==} + engines: {node: '>=0.4.0'} + dependencies: + xml-js: 1.6.11 + dev: true + /fetch-blob@3.1.5: resolution: {integrity: sha512-N64ZpKqoLejlrwkIAnb9iLSA3Vx/kjgzpcDhygcqJ2KKjky8nCgUQ+dzXtbrLaWZGZNmNfQTsiQ0weZ1svglHg==} engines: {node: ^12.20 || >= 14.13} @@ -10120,6 +10130,13 @@ packages: optional: true dev: true + /xml-js@1.6.11: + resolution: {integrity: sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==} + hasBin: true + dependencies: + sax: 1.3.0 + dev: true + /xtend@4.0.2: resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} engines: {node: '>=0.4'}