diff --git a/package.json b/package.json index 8436cade..bdd50a34 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@actions/github": "^5.1.1", "@astrojs/mdx": "^0.19.7", "@astrojs/react": "2.2.1", + "@astrojs/rss": "^4.0.7", "@astrojs/tailwind": "3.1.3", "@cloudinary/url-gen": "^1.10.0", "@emotion/css": "^11.11.0", @@ -36,6 +37,7 @@ "html-react-parser": "^3.0.16", "iso-3166": "^4.2.0", "lucide-react": "^0.220.0", + "markdown-it": "^14.1.0", "markdown-to-jsx": "^7.2.1", "merge-refs": "^1.2.1", "nanostores": "^0.8.1", @@ -49,6 +51,7 @@ "remark-gfm": "^3.0.1", "remark-math": "^5.1.1", "remark-oembed": "^1.2.2", + "sanitize-html": "^2.13.0", "swiper": "^9.3.2", "tailwind-merge": "^1.12.0", "tailwind-scrollbar-hide": "^1.1.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 961c1119..ae930e52 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ importers: '@astrojs/react': specifier: 2.2.1 version: 2.2.1(@types/react-dom@18.2.4)(@types/react@18.2.6)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@astrojs/rss': + specifier: ^4.0.7 + version: 4.0.7 '@astrojs/tailwind': specifier: 3.1.3 version: 3.1.3(astro@2.8.3(@types/node@18.15.3)(sass@1.59.2))(tailwindcss@3.3.2) @@ -86,6 +89,9 @@ importers: lucide-react: specifier: ^0.220.0 version: 0.220.0(react@18.2.0) + markdown-it: + specifier: ^14.1.0 + version: 14.1.0 markdown-to-jsx: specifier: ^7.2.1 version: 7.2.1(react@18.2.0) @@ -125,6 +131,9 @@ importers: remark-oembed: specifier: ^1.2.2 version: 1.2.2 + sanitize-html: + specifier: ^2.13.0 + version: 2.13.0 swiper: specifier: ^9.3.2 version: 9.3.2 @@ -235,6 +244,9 @@ packages: react: ^17.0.2 || ^18.0.0 react-dom: ^17.0.2 || ^18.0.0 + '@astrojs/rss@4.0.7': + resolution: {integrity: sha512-ZEG55XFB19l+DplUvBISmz04UbjDtKliRO4Y5+ERRhAMjgCVVobEBNE6ZwWG1h6orWUocy4nfPihKXDyB73x9g==} + '@astrojs/tailwind@3.1.3': resolution: {integrity: sha512-10S1omrv5K5HRVAZ0fBgN5vQykn2HRL332LAVFyBASMn1Ff6gDfSK+CPUeUu94eZUOEaPnECLK8EHAqZ8iY9CA==} peerDependencies: @@ -1828,6 +1840,10 @@ packages: fast-shallow-equal@1.0.0: resolution: {integrity: sha512-HPtaa38cPgWvaCFmRNhlc6NG7pv6NUHqjPgVAkWGoB9mQMwYB27/K0CvOM5Czy+qpT3e8XJ6Q4aPAnzpNpzNaw==} + fast-xml-parser@4.5.0: + resolution: {integrity: sha512-/PlTQCI96+fZMAOLMZK4CWG1ItCbfZ/0jx7UIJFChPNrx7tcEgerUgWbeieCM9MfHInUDyK8DWYZ+YrywDJuTg==} + hasBin: true + fastest-stable-stringify@2.0.2: resolution: {integrity: sha512-bijHueCGd0LqqNK9b5oCMHc0MluJAx0cwqASgbWMvkO01lCYgIhacVRLcaDz3QnyYIRNJRDwMb41VuT6pHJ91Q==} @@ -2224,6 +2240,9 @@ packages: lines-and-columns@1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} + linkify-it@5.0.0: + resolution: {integrity: sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==} + load-yaml-file@0.2.0: resolution: {integrity: sha512-OfCBkGEw4nN6JLtgRidPX6QxjBQGQf72q3si2uvqyFEMbycSFFHwAZeXx6cJgFM9wmLrf9zBwCP3Ivqa+LLZPw==} engines: {node: '>=6'} @@ -2286,6 +2305,10 @@ packages: resolution: {integrity: sha512-WWC0ZuMzCyDHYCasEGs4IPvLyTGftYwh6wIEOULOF0HXcqZlhwRzrK0w2VUlxWA98xnvb/jszw4ZSkJ6ADpM6Q==} engines: {node: '>=0.10.0'} + markdown-it@14.1.0: + resolution: {integrity: sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==} + hasBin: true + markdown-table@3.0.3: resolution: {integrity: sha512-Z1NL3Tb1M9wH4XESsCDEksWoKTdlUafKc4pt0GRwjUyXaCFZ+dc3g2erqB6zm3szA2IUSi7VnPI+o/9jnxh9hw==} @@ -2361,6 +2384,9 @@ packages: mdn-data@2.0.14: resolution: {integrity: sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==} + mdurl@2.0.0: + resolution: {integrity: sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==} + merge-refs@1.2.1: resolution: {integrity: sha512-pRPz39HQz2xzHdXAGvtJ9S8aEpNgpUjzb5yPC3ytozodmsHg+9nqgRs7/YOmn9fM/TLzntAC8AdGTidKxOq9TQ==} @@ -2655,6 +2681,9 @@ packages: parse-latin@5.0.1: resolution: {integrity: sha512-b/K8ExXaWC9t34kKeDV8kGXBkXZ1HCSAZRYE7HR14eA1GlXX5L8iWhs8USJNhQU9q5ci413jCKF0gOyovvyRBg==} + parse-srcset@1.0.2: + resolution: {integrity: sha512-/2qh0lav6CmI15FzA3i/2Bzk2zCgQhGMkvhOhKNcBVQ1ldgpbfiNTVslmooUmWJcADi1f1kIeynbDRVzNlfR6Q==} + parse5@6.0.1: resolution: {integrity: sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==} @@ -2795,6 +2824,10 @@ packages: pump@3.0.0: resolution: {integrity: sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==} + punycode.js@2.3.1: + resolution: {integrity: sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==} + engines: {node: '>=6'} + pupa@3.1.0: resolution: {integrity: sha512-FLpr4flz5xZTSJxSeaheeMKN/EDzMdK7b8PTOC6a5PYFKTucWbdqjgqaEyH0shFiSJrVB1+Qqi4Tk19ccU6Aug==} engines: {node: '>=12.20'} @@ -2987,6 +3020,9 @@ packages: safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} + sanitize-html@2.13.0: + resolution: {integrity: sha512-Xff91Z+4Mz5QiNSLdLWwjgBDm5b1RU6xBT0+12rapjiaR7SwfRdjw8f+6Rir2MXKLrDicRFHdb51hGOAxmsUIA==} + sass-formatter@0.7.6: resolution: {integrity: sha512-hXdxU6PCkiV3XAiSnX+XLqz2ohHoEnVUlrd8LEVMAI80uB1+OTScIkH9n6qQwImZpTye1r1WG1rbGUteHNhoHg==} @@ -3135,6 +3171,9 @@ packages: resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} engines: {node: '>=12'} + strnum@1.0.5: + resolution: {integrity: sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==} + style-to-js@1.1.3: resolution: {integrity: sha512-zKI5gN/zb7LS/Vm0eUwjmjrXWw8IMtyA8aPBJZdYiQTXj4+wQ3IucOLIOnF7zCHxvW8UhIGh/uZh/t9zEHXNTQ==} @@ -3258,6 +3297,9 @@ packages: engines: {node: '>=12.20'} hasBin: true + uc.micro@2.1.0: + resolution: {integrity: sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==} + undici@5.28.4: resolution: {integrity: sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==} engines: {node: '>=14.0'} @@ -3630,6 +3672,11 @@ snapshots: transitivePeerDependencies: - supports-color + '@astrojs/rss@4.0.7': + dependencies: + fast-xml-parser: 4.5.0 + kleur: 4.1.5 + '@astrojs/tailwind@3.1.3(astro@2.8.3(@types/node@18.15.3)(sass@1.59.2))(tailwindcss@3.3.2)': dependencies: '@proload/core': 0.3.3 @@ -5393,6 +5440,10 @@ snapshots: fast-shallow-equal@1.0.0: {} + fast-xml-parser@4.5.0: + dependencies: + strnum: 1.0.5 + fastest-stable-stringify@2.0.2: {} fastq@1.15.0: @@ -5838,6 +5889,10 @@ snapshots: lines-and-columns@1.2.4: {} + linkify-it@5.0.0: + dependencies: + uc.micro: 2.1.0 + load-yaml-file@0.2.0: dependencies: graceful-fs: 4.2.10 @@ -5896,6 +5951,15 @@ snapshots: markdown-extensions@1.1.1: {} + markdown-it@14.1.0: + dependencies: + argparse: 2.0.1 + entities: 4.5.0 + linkify-it: 5.0.0 + mdurl: 2.0.0 + punycode.js: 2.3.1 + uc.micro: 2.1.0 + markdown-table@3.0.3: {} markdown-to-jsx@7.2.1(react@18.2.0): @@ -6084,6 +6148,8 @@ snapshots: mdn-data@2.0.14: {} + mdurl@2.0.0: {} + merge-refs@1.2.1: dependencies: '@types/react': 18.2.6 @@ -6552,6 +6618,8 @@ snapshots: unist-util-modify-children: 3.1.1 unist-util-visit-children: 2.0.2 + parse-srcset@1.0.2: {} + parse5@6.0.1: {} parse5@7.1.2: @@ -6681,6 +6749,8 @@ snapshots: end-of-stream: 1.4.4 once: 1.4.0 + punycode.js@2.3.1: {} + pupa@3.1.0: dependencies: escape-goat: 4.0.0 @@ -6957,6 +7027,15 @@ snapshots: safe-buffer@5.2.1: {} + sanitize-html@2.13.0: + dependencies: + deepmerge: 4.3.0 + escape-string-regexp: 4.0.0 + htmlparser2: 8.0.2 + is-plain-object: 5.0.0 + parse-srcset: 1.0.2 + postcss: 8.4.31 + sass-formatter@0.7.6: dependencies: suf-log: 2.5.3 @@ -7091,6 +7170,8 @@ snapshots: strip-final-newline@3.0.0: {} + strnum@1.0.5: {} + style-to-js@1.1.3: dependencies: style-to-object: 0.4.1 @@ -7226,6 +7307,8 @@ snapshots: typescript@5.0.4: {} + uc.micro@2.1.0: {} + undici@5.28.4: dependencies: '@fastify/busboy': 2.0.0 diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 62da855d..e2be0caf 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -38,6 +38,7 @@ if (title) { + ): Date { + return new Date(`${post.data.year}-${post.data.month}-${post.data.day}`); +} + +export async function get(context: SiteContext) { + const posts = await getCollection('blog'); + // Sort the posts by date in descending order + const sortedPosts = posts.sort((a, b) => { + return getDateFromPost(b).getTime() - getDateFromPost(a).getTime(); + }); + return rss({ + title: 'Unitary Fund blog', + description: 'Unitary Fund blog', + site: context.site, + items: sortedPosts + .map((post) => ({ + title: post.data.title, + link: `/posts/${post.slug}/`, + pubDate: getDateFromPost(post), + content: sanitizeHtml(parser.render(post.body)), + })), + customData: `en-us`, + }); +}