diff --git a/src/consts.ts b/src/consts.ts index 1f03f7e..bdd598a 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -2,4 +2,4 @@ // You can import this data from anywhere in your site by using the `import` keyword. export const SITE_TITLE = 'Pantosite'; -export const SITE_DESCRIPTION = 'The personal Blog of one Anton Pogrebnjak'; +export const SITE_DESCRIPTION = 'The personal website of Anton'; diff --git a/src/pages/blog/rss.xml.js b/src/pages/blog/rss.xml.js new file mode 100644 index 0000000..bbaf2db --- /dev/null +++ b/src/pages/blog/rss.xml.js @@ -0,0 +1,17 @@ +import rss from '@astrojs/rss'; +import { getCollection } from 'astro:content'; +import { SITE_TITLE, SITE_DESCRIPTION } from '../../consts'; + +export async function GET(context) { + const posts = await getCollection('blog'); + + return rss({ + title: SITE_TITLE, + description: SITE_DESCRIPTION, + site: context.site, + items: posts.map((post) => ({ + ...post.data, + link: `/blog/${post.id}/`, + })), + }); +} diff --git a/src/pages/projects/rss.xml.js b/src/pages/projects/rss.xml.js new file mode 100644 index 0000000..bae43b3 --- /dev/null +++ b/src/pages/projects/rss.xml.js @@ -0,0 +1,17 @@ +import rss from '@astrojs/rss'; +import { getCollection } from 'astro:content'; +import { SITE_TITLE, SITE_DESCRIPTION } from '../../consts'; + +export async function GET(context) { + const posts = await getCollection('projects'); + + return rss({ + title: SITE_TITLE, + description: SITE_DESCRIPTION, + site: context.site, + items: posts.map((post) => ({ + ...post.data, + link: `/projects/${post.id}/`, + })), + }); +} diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js index ae5e4c4..69a6cdc 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/rss.xml.js @@ -3,14 +3,22 @@ import { getCollection } from 'astro:content'; import { SITE_TITLE, SITE_DESCRIPTION } from '../consts'; export async function GET(context) { - const posts = await getCollection('blog'); - return rss({ - title: SITE_TITLE, - description: SITE_DESCRIPTION, - site: context.site, - items: posts.map((post) => ({ - ...post.data, - link: `/blog/${post.id}/`, - })), - }); + const posts = await getCollection('blog'); + const projects = await getCollection('projects'); + + let unifiedItems = posts.map((post) => ({ + ...post.data, + link: `/blog/${post.id}/`, + })).concat(projects.map((project) => ({ + ...project.data, + link: `/projects/${project.id}/` + }))); + unifiedItems = unifiedItems.sort((a, b) => b.pubDate - a.pubDate); + + return rss({ + title: SITE_TITLE, + description: SITE_DESCRIPTION, + site: context.site, + items: unifiedItems, + }); }