diff --git a/packages/rss/README.md b/packages/rss/README.md new file mode 100644 index 00000000..af5f1a3e --- /dev/null +++ b/packages/rss/README.md @@ -0,0 +1,28 @@ +# @galactiks/rss + +This package get articles from [Galactiks](https://www.galactiks.com) content and generate RSS/Atom feeds from this content. + +## Installation + +Install the `@galactiks/rss` package using your preferred package manager: + +```sh +# npm +npm i @galactiks/rss + +# yarn +yarn add @galactiks/rss + +# pnpm +pnpm i @galactiks/rss +``` + +If you run into any issues, [feel free to report them to us on GitHub](https://github.com/thegalactiks/explorer/issues). + +## Getting started + +Coming soon + +## License + +MIT © [Galactiks](https://www.galactiks.com) diff --git a/packages/rss/package.json b/packages/rss/package.json new file mode 100644 index 00000000..9538c690 --- /dev/null +++ b/packages/rss/package.json @@ -0,0 +1,41 @@ +{ + "name": "@galactiks/rss", + "version": "0.2.1", + "description": "Generate RSS and Atom feeds from Galactiks content", + "author": "thegalactiks", + "types": "./dist/index.d.mts", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "bugs": "https://github.com/thegalactiks/explorer/issues", + "homepage": "https://www.galactiks.com", + "repository": { + "type": "git", + "url": "https://github.com/thegalactiks/explorer.git", + "directory": "packages/rss" + }, + "main": "dist/index.mjs", + "scripts": { + "build": "tsc -p ./tsconfig.json", + "build:ci": "tsc -p ./tsconfig.json" + }, + "exports": { + "./package.json": "./package.json", + ".": "./dist/index.mjs" + }, + "files": [ + "dist" + ], + "keywords": [ + "galactiks", + "rss", + "atom", + "feed" + ], + "dependencies": { + "@galactiks/config": "workspace:^", + "@galactiks/explorer": "workspace:^", + "feed": "4.2.2" + } +} diff --git a/packages/rss/src/index.mts b/packages/rss/src/index.mts new file mode 100644 index 00000000..f8711379 --- /dev/null +++ b/packages/rss/src/index.mts @@ -0,0 +1,39 @@ +import { getConfig, getDefaultLanguage } from '@galactiks/config'; +import { getWebPageDocumentsByType } from '@galactiks/explorer'; +import { Feed } from 'feed'; + +const galactiksConfig = getConfig(); + +export async function getRSS() { + const articles = await getWebPageDocumentsByType('Article'); + + const feed = new Feed({ + title: galactiksConfig.webManifest.name, + description: galactiksConfig.webManifest.description, + id: galactiksConfig.name || galactiksConfig.webManifest.name, + link: galactiksConfig.webManifest.start_url, + language: getDefaultLanguage(), + copyright: '', + generator: 'Galactiks', + }); + + articles.forEach((article) => { + feed.addItem({ + title: article.name, + id: article.url, + link: article.url, + date: article.datePublished, + image: article.image?.contentUrl, + description: article.description, + author: article.author && [ + { + name: article.author.name, + email: article.author.email, + link: article.author.url, + }, + ], + }); + }); + + return feed; +} diff --git a/packages/rss/tsconfig.json b/packages/rss/tsconfig.json new file mode 100644 index 00000000..569016e9 --- /dev/null +++ b/packages/rss/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["src"], + "compilerOptions": { + "allowJs": true, + "target": "ES2021", + "module": "ES2022", + "outDir": "./dist" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 439b8d32..18aed1b1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,9 +1,5 @@ lockfileVersion: '6.0' -settings: - autoInstallPeers: false - excludeLinksFromLockfile: false - overrides: '@opentelemetry/api': 1.4.1 '@opentelemetry/core': 1.13.0 @@ -75,9 +71,6 @@ importers: '@astrojs/react': specifier: 3.0.2 version: 3.0.2(@types/react-dom@18.2.7)(@types/react@18.2.22)(react-dom@18.2.0)(react@18.2.0) - '@astrojs/rss': - specifier: 3.0.0 - version: 3.0.0 '@astrojs/sitemap': specifier: 3.0.0 version: 3.0.0 @@ -171,6 +164,18 @@ importers: specifier: 1.1.2 version: 1.1.2(typescript@5.2.2) + packages/rss: + dependencies: + '@galactiks/config': + specifier: workspace:^ + version: link:../config + '@galactiks/explorer': + specifier: workspace:^ + version: link:../explorer + feed: + specifier: 4.2.2 + version: 4.2.2 + packages: /@aashutoshrathi/word-wrap@1.2.6: @@ -262,13 +267,6 @@ packages: - vite dev: true - /@astrojs/rss@3.0.0: - resolution: {integrity: sha512-PMX8iqByk9gtOrusikten/oF5uHjOCZigL6RuXFBUu+xtdKQxXzfIohJ99V2haA4FJjVDyibDTGzXR81POBMxQ==} - dependencies: - fast-xml-parser: 4.2.7 - kleur: 4.1.5 - dev: true - /@astrojs/sitemap@3.0.0: resolution: {integrity: sha512-qm7npHuUW4q3OOmulqhJ1g69jEQu0Sdc6P8NbOzqIoosj/L+3v4i8dtKBnp6n1UQ4Sx8H8Vdi3Z/On7i9/ZJhw==} dependencies: @@ -879,10 +877,10 @@ packages: resolution: {integrity: sha512-47gAg0O2pW5Jlo86jfzjdkwL5a7Bzb+Kj5WTmdu4CxYRfWn9ytKjuuYIfsNDW8neuhdKzn+P5wCddgEh0glYyQ==} peerDependencies: '@effect-ts/core': ^0.60.2 - '@opentelemetry/api': 1.4.1 - '@opentelemetry/core': 1.13.0 - '@opentelemetry/exporter-trace-otlp-grpc': 0.39.1 - '@opentelemetry/sdk-trace-base': 1.13.0 + '@opentelemetry/api': ^1.4.0 + '@opentelemetry/core': ^1.13.0 + '@opentelemetry/exporter-trace-otlp-grpc': ^0.39.0 + '@opentelemetry/sdk-trace-base': ^1.13.0 dependencies: '@effect-ts/core': 0.60.5 '@effect-ts/otel': 0.15.1(@effect-ts/core@0.60.5)(@opentelemetry/api@1.4.1)(@opentelemetry/core@1.13.0)(@opentelemetry/sdk-trace-base@1.13.0) @@ -896,10 +894,10 @@ packages: resolution: {integrity: sha512-a2sF0ylmn8xOJs8fNeT/spJ1gUcsksAJCALxo9WOfuTCMtTwMVtVhCKEPEeQoL7wFqU+JgPkVdP91+FJ/Rkeow==} peerDependencies: '@effect-ts/core': ^0.60.2 - '@opentelemetry/api': 1.4.1 - '@opentelemetry/core': 1.13.0 - '@opentelemetry/sdk-trace-base': 1.13.0 - '@opentelemetry/sdk-trace-node': 1.13.0 + '@opentelemetry/api': ^1.4.0 + '@opentelemetry/core': ^1.13.0 + '@opentelemetry/sdk-trace-base': ^1.13.0 + '@opentelemetry/sdk-trace-node': ^1.13.0 dependencies: '@effect-ts/core': 0.60.5 '@effect-ts/otel': 0.15.1(@effect-ts/core@0.60.5)(@opentelemetry/api@1.4.1)(@opentelemetry/core@1.13.0)(@opentelemetry/sdk-trace-base@1.13.0) @@ -913,9 +911,9 @@ packages: resolution: {integrity: sha512-AmZJHl7t0+Peh7Yb2+hqn6r9+rd9/UfeA4AMV9h0YGTdOyouyFfD3wzWlxnAUzAQ4Lrod4kC7Noruret4EpqpA==} peerDependencies: '@effect-ts/core': ^0.60.2 - '@opentelemetry/api': 1.4.1 - '@opentelemetry/core': 1.13.0 - '@opentelemetry/sdk-trace-base': 1.13.0 + '@opentelemetry/api': ^1.4.0 + '@opentelemetry/core': ^1.13.0 + '@opentelemetry/sdk-trace-base': ^1.13.0 dependencies: '@effect-ts/core': 0.60.5 '@opentelemetry/api': 1.4.1 @@ -1557,7 +1555,7 @@ packages: resolution: {integrity: sha512-pS5fU4lrRjOIPZQqA2V1SUM9QUFXbO+8flubAiy6ntLjnAjJJUdRFOUOxK6v86ZHI2p2S8A0vD0BTu95FZYvjA==} engines: {node: '>=14'} peerDependencies: - '@opentelemetry/api': 1.4.1 + '@opentelemetry/api': '>=1.0.0 <1.5.0' dependencies: '@opentelemetry/api': 1.4.1 dev: true @@ -1566,7 +1564,7 @@ packages: resolution: {integrity: sha512-2dBX3Sj99H96uwJKvc2w9NOiNgbvAO6mOFJFramNkKfS9O4Um+VWgpnlAazoYjT6kUJ1MP70KQ5ngD4ed+4NUw==} engines: {node: '>=14'} peerDependencies: - '@opentelemetry/api': 1.4.1 + '@opentelemetry/api': '>=1.0.0 <1.5.0' dependencies: '@opentelemetry/api': 1.4.1 '@opentelemetry/semantic-conventions': 1.13.0 @@ -1576,7 +1574,7 @@ packages: resolution: {integrity: sha512-l5RhLKx6U+yuLhMrtgavTDthX50E1mZM3/SSySC7OPZiArFHV/b/9x9jxAzrOgIQUDxyj4N0V9aLKSA2t7Qzxg==} engines: {node: '>=14'} peerDependencies: - '@opentelemetry/api': 1.4.1 + '@opentelemetry/api': ^1.0.0 dependencies: '@grpc/grpc-js': 1.8.18 '@opentelemetry/api': 1.4.1 @@ -1591,7 +1589,7 @@ packages: resolution: {integrity: sha512-Pv5X8fbi6jD/RJBePyn7MnCSuE6MbPB6dl+7YYBWJ5RcMGYMwvLXjd4h2jWsPV2TSUg38H/RoSP0aXvQ06Y7iw==} engines: {node: '>=14'} peerDependencies: - '@opentelemetry/api': 1.4.1 + '@opentelemetry/api': ^1.0.0 dependencies: '@opentelemetry/api': 1.4.1 '@opentelemetry/core': 1.13.0(@opentelemetry/api@1.4.1) @@ -1601,7 +1599,7 @@ packages: resolution: {integrity: sha512-u3ErFRQqQFKjjIMuwLWxz/tLPYInfmiAmSy//fGSCzCh2ZdJgqQjMOAxBgqFtCF2xFL+OmMhyuC2ThMzceGRWA==} engines: {node: '>=14'} peerDependencies: - '@opentelemetry/api': 1.4.1 + '@opentelemetry/api': ^1.0.0 dependencies: '@grpc/grpc-js': 1.8.18 '@opentelemetry/api': 1.4.1 @@ -1614,7 +1612,7 @@ packages: resolution: {integrity: sha512-0hgVnXXz5efI382B/24NxD4b6Zxlh7nxCdJkxkdmQMbn0yRiwoq/ZT+QG8eUL6JNzsBAV1WJlF5aJNsL8skHvw==} engines: {node: '>=14'} peerDependencies: - '@opentelemetry/api': 1.4.1 + '@opentelemetry/api': '>=1.3.0 <1.5.0' dependencies: '@opentelemetry/api': 1.4.1 '@opentelemetry/api-logs': 0.39.1 @@ -1629,7 +1627,7 @@ packages: resolution: {integrity: sha512-HOo91EI4UbuG8xQVLFziTzrcIn0MJQhy8m9jorh8aonb94jFVFi3CFNIiAnIGOabmnshJLOABxpYXsiPB8Xnzg==} engines: {node: '>=14'} peerDependencies: - '@opentelemetry/api': 1.4.1 + '@opentelemetry/api': '>=1.0.0 <1.5.0' dependencies: '@opentelemetry/api': 1.4.1 '@opentelemetry/core': 1.13.0(@opentelemetry/api@1.4.1) @@ -1639,7 +1637,7 @@ packages: resolution: {integrity: sha512-IV9TO+u1Jzm9mUDAD3gyXf89eyvgEJUY1t+GB5QmS4wjVeWrSMUtD0JjH3yG9SNqkrQOqOGJq7YUSSetW+Lf5Q==} engines: {node: '>=14'} peerDependencies: - '@opentelemetry/api': 1.4.1 + '@opentelemetry/api': '>=1.0.0 <1.5.0' dependencies: '@opentelemetry/api': 1.4.1 '@opentelemetry/core': 1.13.0(@opentelemetry/api@1.4.1) @@ -1649,7 +1647,7 @@ packages: resolution: {integrity: sha512-euqjOkiN6xhjE//0vQYGvbStxoD/WWQRhDiO0OTLlnLBO9Yw2Gd/VoSx2H+svsebjzYk5OxLuREBmcdw6rbUNg==} engines: {node: '>=14'} peerDependencies: - '@opentelemetry/api': 1.4.1 + '@opentelemetry/api': '>=1.0.0 <1.5.0' dependencies: '@opentelemetry/api': 1.4.1 '@opentelemetry/core': 1.13.0(@opentelemetry/api@1.4.1) @@ -1660,7 +1658,7 @@ packages: resolution: {integrity: sha512-/gmgKfZ1ZVFporKuwsewqIyvaUIGpv76JZ7lBpHQQPb37IMpaXO6pdqFI4ebHAWfNIm3akMyhmdtzivcgF3lgw==} engines: {node: '>=14'} peerDependencies: - '@opentelemetry/api': 1.4.1 + '@opentelemetry/api': '>=1.4.0 <1.5.0' '@opentelemetry/api-logs': '>=0.38.0' dependencies: '@opentelemetry/api': 1.4.1 @@ -1673,7 +1671,7 @@ packages: resolution: {integrity: sha512-MOjZX6AnSOqLliCcZUrb+DQKjAWXBiGeICGbHAGe5w0BB18PJIeIo995lO5JSaFfHpmUMgJButTPfJJD27W3Vg==} engines: {node: '>=14'} peerDependencies: - '@opentelemetry/api': 1.4.1 + '@opentelemetry/api': '>=1.3.0 <1.5.0' dependencies: '@opentelemetry/api': 1.4.1 '@opentelemetry/core': 1.13.0(@opentelemetry/api@1.4.1) @@ -1685,7 +1683,7 @@ packages: resolution: {integrity: sha512-moTiQtc0uPR1hQLt6gLDJH9IIkeBhgRb71OKjNHZPE1VF45fHtD6nBDi5J/DkTHTwYP5X3kBJLa3xN7ub6J4eg==} engines: {node: '>=14'} peerDependencies: - '@opentelemetry/api': 1.4.1 + '@opentelemetry/api': '>=1.0.0 <1.5.0' dependencies: '@opentelemetry/api': 1.4.1 '@opentelemetry/core': 1.13.0(@opentelemetry/api@1.4.1) @@ -1697,7 +1695,7 @@ packages: resolution: {integrity: sha512-FXA85lXKTsnbOflA/TBuBf2pmhD3c8uDjNjG0YqK+ap8UayfALmfJhf+aG1yBOUHevCY0JXJ4/xtbXExxpsMog==} engines: {node: '>=14'} peerDependencies: - '@opentelemetry/api': 1.4.1 + '@opentelemetry/api': '>=1.0.0 <1.5.0' dependencies: '@opentelemetry/api': 1.4.1 '@opentelemetry/context-async-hooks': 1.13.0(@opentelemetry/api@1.4.1) @@ -1831,7 +1829,7 @@ packages: /@types/hast@2.3.4: resolution: {integrity: sha512-wLEm0QvaoawEDoTRwzTXp4b4jpwiJDvR5KMnFnVodm3scufTlBOWRD6N1OBf9TZMhjlNsSfcO5V+7AF4+Vy+9g==} dependencies: - '@types/unist': 3.0.0 + '@types/unist': 2.0.6 /@types/is-ci@3.0.0: resolution: {integrity: sha512-Q0Op0hdWbYd1iahB+IFNQcWXFq4O0Q5MwQP7uN0souuQ4rPg1vEYcnIOfr1gY+M+6rc8FGoRaBO1mOOvL29sEQ==} @@ -1864,7 +1862,7 @@ packages: /@types/mdast@3.0.11: resolution: {integrity: sha512-Y/uImid8aAwrEA24/1tcRZwpxX3pIFTSilcNDKSPn+Y2iDywSEachzRuvgAYYLR3wpGXAsMbv5lvKLDZLeYPAw==} dependencies: - '@types/unist': 3.0.0 + '@types/unist': 2.0.6 /@types/mdast@4.0.0: resolution: {integrity: sha512-YLeG8CujC9adtj/kuDzq1N4tCDYKoZ5l/bnjq8d74+t/3q/tHquJOJKUQXJrLCflOHpKjXgcI/a929gpmLOEng==} @@ -1960,6 +1958,7 @@ packages: /@types/unist@3.0.0: resolution: {integrity: sha512-MFETx3tbTjE7Uk6vvnWINA/1iJ7LuMdO4fcq8UfF0pRbj01aGLduVvQcRyswuACJdpnHgg8E3rQLhaRdNEJS0w==} + dev: true /@typescript-eslint/eslint-plugin@6.7.2(@typescript-eslint/parser@6.7.2)(eslint@8.50.0)(typescript@5.2.2): resolution: {integrity: sha512-ooaHxlmSgZTM6CHYAFRlifqh1OAr3PAQEwi7lhYhaegbnXrnh7CDcHmc3+ihhbQC7H0i4JF0psI5ehzkF6Yl6Q==} @@ -3517,13 +3516,6 @@ packages: resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} dev: true - /fast-xml-parser@4.2.7: - resolution: {integrity: sha512-J8r6BriSLO1uj2miOk1NW0YVm8AGOOu3Si2HQp/cSmo6EA4m3fcwu2WKjJ4RK9wMLBtg69y1kS8baDiQBR41Ig==} - hasBin: true - dependencies: - strnum: 1.0.5 - dev: true - /fastq@1.15.0: resolution: {integrity: sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==} dependencies: @@ -3535,6 +3527,13 @@ packages: dependencies: format: 0.2.2 + /feed@4.2.2: + resolution: {integrity: sha512-u5/sxGfiMfZNtJ3OvQpXcvotFpYkL0n9u9mM2vkui2nGo8b4wvDkJ8gAkYqbA8QpGyFCv3RK0Z+Iv+9veCS9bQ==} + engines: {node: '>=0.4.0'} + dependencies: + xml-js: 1.6.11 + dev: false + /fetch-blob@3.2.0: resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==} engines: {node: ^12.20 || >= 14.13} @@ -6216,7 +6215,6 @@ packages: /sax@1.2.4: resolution: {integrity: sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==} - dev: true /scheduler@0.23.0: resolution: {integrity: sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==} @@ -6638,10 +6636,6 @@ packages: engines: {node: '>=8'} dev: true - /strnum@1.0.5: - resolution: {integrity: sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==} - dev: true - /style-to-object@0.4.1: resolution: {integrity: sha512-HFpbb5gr2ypci7Qw+IOhnP2zOU7e77b+rzM+wTzXzfi1PrtBCX0E7Pk4wL4iTLnhzZ+JgEGAhX81ebTg/aYjQw==} dependencies: @@ -7338,6 +7332,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.2.4 + dev: false + /xtend@4.0.2: resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} engines: {node: '>=0.4'} @@ -7449,3 +7450,7 @@ packages: /zwitch@2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} + +settings: + autoInstallPeers: false + excludeLinksFromLockfile: false