diff --git a/apps/website/docs/.vitepress/config.js b/apps/website/docs/.vitepress/config.js index 7473250c..72bf0938 100644 --- a/apps/website/docs/.vitepress/config.js +++ b/apps/website/docs/.vitepress/config.js @@ -1,8 +1,12 @@ import { defineConfig } from 'vitepress'; import { createSidebar } from './sidebar_creator'; +import { rss } from './rss'; export default defineConfig({ - lang: 'en-US', + async buildEnd(config) { + await rss.onBuildEnd(config); + }, + lang: 'en', title: 'With Ease', description: 'A set of libraries and recipes to make frontend development easier thanks to Effector', @@ -19,7 +23,7 @@ export default defineConfig({ logo: '/logo.svg', footer: { message: 'Released under the MIT License.', - copyright: 'Copyright © 2023-present Igor Kamyşev', + copyright: 'Copyright © 2023-present, Igor Kamyşev', }, socialLinks: [ { icon: 'github', link: 'https://github.com/igorkamyshev/withease' }, diff --git a/apps/website/docs/.vitepress/rss.js b/apps/website/docs/.vitepress/rss.js new file mode 100644 index 00000000..052fd932 --- /dev/null +++ b/apps/website/docs/.vitepress/rss.js @@ -0,0 +1,45 @@ +import path from 'node:path'; +import { writeFile } from 'node:fs/promises'; +import { Feed } from 'feed'; +import { createContentLoader } from 'vitepress'; + +export const rss = { + async onBuildEnd(config) { + const hostname = 'https://withease.pages.dev'; + + const feed = new Feed({ + title: 'With Ease Magazine', + description: + 'The collection of articles about Effector and related topics. It is not a replacement for the official documentation, but it can help you to understand some concepts better.', + id: hostname, + link: hostname, + language: 'en', + favicon: `${hostname}/favicon.ico`, + copyright: 'Copyright (c) 2023-present, Igor Kamyşev', + }); + + const posts = await createContentLoader('/magazine/*.md', { + excerpt: true, + render: true, + }).load(); + + posts.sort( + (a, b) => +new Date(b.frontmatter.date) - +new Date(a.frontmatter.date) + ); + + for (const { url, excerpt, frontmatter, html } of posts) { + console.log(rest); + feed.addItem({ + title: frontmatter.title, + id: `${hostname}${url}`, + link: `${hostname}${url}`, + description: excerpt, + content: html, + author: [], + date: frontmatter.date, + }); + } + + await writeFile(path.join(config.outDir, 'feed.rss'), feed.rss2()); + }, +}; diff --git a/package.json b/package.json index 5a982de4..bab6ddcf 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "effector": "23.0.0", "effector-vue": "23.0.0", "eslint": "8.46.0", + "feed": "^4.2.2", "glob": "^8.0.3", "i18next": "23.0.0", "nx": "16.5.x", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cb434675..573e75e3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -31,6 +31,7 @@ importers: effector: 23.0.0 effector-vue: 23.0.0 eslint: 8.46.0 + feed: ^4.2.2 glob: ^8.0.3 i18next: 23.0.0 nx: 16.5.x @@ -80,6 +81,7 @@ importers: effector: 23.0.0 effector-vue: 23.0.0_effector@23.0.0+vue@3.3.4 eslint: 8.46.0 + feed: 4.2.2 glob: 8.1.0 i18next: 23.0.0 nx: 16.5.5 @@ -5527,6 +5529,13 @@ packages: reusify: 1.0.4 dev: true + /feed/4.2.2: + resolution: {integrity: sha512-u5/sxGfiMfZNtJ3OvQpXcvotFpYkL0n9u9mM2vkui2nGo8b4wvDkJ8gAkYqbA8QpGyFCv3RK0Z+Iv+9veCS9bQ==} + engines: {node: '>=0.4.0'} + dependencies: + xml-js: 1.6.11 + dev: true + /fflate/0.8.0: resolution: {integrity: sha512-FAdS4qMuFjsJj6XHbBaZeXOgaypXp8iw/Tpyuq/w3XA41jjLHT8NPA+n7czH/DDhdncq0nAyDZmPeWXh2qmdIg==} dev: true @@ -8025,6 +8034,10 @@ packages: vue: 3.3.4 dev: false + /sax/1.3.0: + resolution: {integrity: sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==} + dev: true + /secure-compare/3.0.1: resolution: {integrity: sha512-AckIIV90rPDcBcglUwXPF3kg0P0qmPsPXAj6BBEENQE1p5yA1xfmDJzfi1Tappj37Pv2mVbKpL3Z1T+Nn7k1Qw==} dev: true @@ -9117,6 +9130,13 @@ packages: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} dev: true + /xml-js/1.6.11: + resolution: {integrity: sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==} + hasBin: true + dependencies: + sax: 1.3.0 + dev: true + /y18n/4.0.3: resolution: {integrity: sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==} dev: true