From 3d7ce1995e568e1ce513a9ac97b07530a5e9367d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Kamy=C5=9Fev?= Date: Thu, 11 Apr 2024 13:06:08 +0700 Subject: [PATCH] RSS feed for Magazine (#80) --- apps/website/docs/.vitepress/config.js | 8 +++- apps/website/docs/.vitepress/rss.js | 45 +++++++++++++++++++ .../docs/magazine/dependency_injection.md | 1 + apps/website/docs/magazine/explicit_start.md | 1 + apps/website/docs/magazine/fork_api_rules.md | 1 + .../website/docs/magazine/global_variables.md | 1 + .../handle_events_in_ui_frameworks.md | 1 + apps/website/docs/magazine/index.md | 1 + .../docs/magazine/migration_from_redux.md | 5 +++ apps/website/docs/magazine/no_domains.md | 1 + apps/website/docs/magazine/no_methods.md | 1 + apps/website/docs/magazine/watch_calls.md | 1 + package.json | 2 + pnpm-lock.yaml | 26 +++++++++++ 14 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 apps/website/docs/.vitepress/rss.js 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..4f9d8f35 --- /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'; +import { compareAsc } from 'date-fns'; + +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 pages = await createContentLoader('/magazine/*.md', { + excerpt: true, + render: true, + }).load(); + + const posts = pages.filter((page) => page.frontmatter.rss ?? true); + + posts.sort((a, b) => compareAsc(b.frontmatter.date, a.frontmatter.date)); + + for (const { url, excerpt, frontmatter, html } of posts) { + 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/apps/website/docs/magazine/dependency_injection.md b/apps/website/docs/magazine/dependency_injection.md index 9528c510..d781b6e8 100644 --- a/apps/website/docs/magazine/dependency_injection.md +++ b/apps/website/docs/magazine/dependency_injection.md @@ -1,5 +1,6 @@ --- title: Dependency injection +date: 2023-06-19 --- # Dependency injection diff --git a/apps/website/docs/magazine/explicit_start.md b/apps/website/docs/magazine/explicit_start.md index e78b2d8c..154575f1 100644 --- a/apps/website/docs/magazine/explicit_start.md +++ b/apps/website/docs/magazine/explicit_start.md @@ -1,5 +1,6 @@ --- title: Explicit start of the app +date: 2024-01-26 --- # Explicit start of the app diff --git a/apps/website/docs/magazine/fork_api_rules.md b/apps/website/docs/magazine/fork_api_rules.md index 6cf4b95e..000c4f7a 100644 --- a/apps/website/docs/magazine/fork_api_rules.md +++ b/apps/website/docs/magazine/fork_api_rules.md @@ -1,5 +1,6 @@ --- title: Fork API rules +date: 2024-01-26 --- # Fork API rules diff --git a/apps/website/docs/magazine/global_variables.md b/apps/website/docs/magazine/global_variables.md index 6f75bdd0..b51743bd 100644 --- a/apps/website/docs/magazine/global_variables.md +++ b/apps/website/docs/magazine/global_variables.md @@ -1,5 +1,6 @@ --- title: Global variables +date: 2023-01-02 --- # Global variables diff --git a/apps/website/docs/magazine/handle_events_in_ui_frameworks.md b/apps/website/docs/magazine/handle_events_in_ui_frameworks.md index c49fb006..2e800b9b 100644 --- a/apps/website/docs/magazine/handle_events_in_ui_frameworks.md +++ b/apps/website/docs/magazine/handle_events_in_ui_frameworks.md @@ -1,6 +1,7 @@ --- outline: [2, 3] title: Handle Effector's Events in UI-frameworks +date: 2024-01-26 --- # Handle Effector's _Events_ in UI-frameworks diff --git a/apps/website/docs/magazine/index.md b/apps/website/docs/magazine/index.md index d351a652..f612e248 100644 --- a/apps/website/docs/magazine/index.md +++ b/apps/website/docs/magazine/index.md @@ -1,5 +1,6 @@ --- sidebar: false +rss: false --- # Magazine diff --git a/apps/website/docs/magazine/migration_from_redux.md b/apps/website/docs/magazine/migration_from_redux.md index 6a3666c6..992d3e6a 100644 --- a/apps/website/docs/magazine/migration_from_redux.md +++ b/apps/website/docs/magazine/migration_from_redux.md @@ -1,3 +1,8 @@ +--- +title: Migrating from Redux to Effector +date: 2024-03-08 +--- + # Migrating from Redux to Effector This guide explains how to perform a gradual, non-blocking code migration from Redux to Effector. diff --git a/apps/website/docs/magazine/no_domains.md b/apps/website/docs/magazine/no_domains.md index ebe85bb4..7a5c44c1 100644 --- a/apps/website/docs/magazine/no_domains.md +++ b/apps/website/docs/magazine/no_domains.md @@ -1,5 +1,6 @@ --- title: You Don't Need Domains +date: 2024-01-26 --- # You Don't Need Domains diff --git a/apps/website/docs/magazine/no_methods.md b/apps/website/docs/magazine/no_methods.md index ef46fe78..9d8bcc09 100644 --- a/apps/website/docs/magazine/no_methods.md +++ b/apps/website/docs/magazine/no_methods.md @@ -1,5 +1,6 @@ --- title: Prefer Operators to Methods +date: 2024-01-26 --- # Prefer Operators to Methods diff --git a/apps/website/docs/magazine/watch_calls.md b/apps/website/docs/magazine/watch_calls.md index e7256e42..66bc8a62 100644 --- a/apps/website/docs/magazine/watch_calls.md +++ b/apps/website/docs/magazine/watch_calls.md @@ -1,5 +1,6 @@ --- title: .watch calls are (not) weird +date: 2024-01-26 --- # `.watch` calls are (not) weird diff --git a/package.json b/package.json index 5a982de4..66d503d7 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", @@ -65,6 +66,7 @@ }, "dependencies": { "@algolia/client-search": "^4.14.3", + "date-fns": "^3.6.0", "sandpack-vue3": "^3.1.7" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cb434675..ad56d8ea 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,9 +28,11 @@ importers: '@vitest/coverage-c8': ~0.32.0 '@vitest/ui': 0.34.4 bytes-iec: ^3.1.1 + date-fns: ^3.6.0 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 @@ -52,6 +54,7 @@ importers: vue: 3.3.4 dependencies: '@algolia/client-search': 4.14.3 + date-fns: 3.6.0 sandpack-vue3: 3.1.7_vue@3.3.4 devDependencies: '@babel/core': 7.18.6 @@ -80,6 +83,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 @@ -4987,6 +4991,10 @@ packages: stream-transform: 2.1.3 dev: true + /date-fns/3.6.0: + resolution: {integrity: sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==} + dev: false + /debug/3.2.7: resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} peerDependencies: @@ -5527,6 +5535,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 +8040,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 +9136,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