From f0e73cf90005709e20b2f16f63d67d6802af3332 Mon Sep 17 00:00:00 2001 From: Pauline Date: Mon, 22 Jan 2024 04:27:34 +0100 Subject: feat(layout): add seo metadata to all pages --- apps/website/src/pages/about.astro | 2 +- apps/website/src/pages/blog/index.astro | 8 +++--- apps/website/src/pages/branding.astro | 2 +- apps/website/src/pages/contact.astro | 2 +- apps/website/src/pages/index.astro | 2 +- apps/website/src/pages/legal/ip.astro | 2 +- apps/website/src/pages/legal/privacy.astro | 2 +- apps/website/src/pages/legal/security.astro | 2 +- apps/website/src/pages/legal/terms.astro | 2 +- apps/website/src/pages/mods.astro | 2 +- apps/website/src/pages/oss.astro | 2 +- .../src/pages/projects/oneconfig/download.astro | 2 +- .../src/pages/projects/oneconfig/index.astro | 2 +- apps/website/src/pages/rss.xml.js | 16 ------------ apps/website/src/pages/rss.xml.ts | 30 ++++++++++++++++++++++ 15 files changed, 45 insertions(+), 33 deletions(-) delete mode 100644 apps/website/src/pages/rss.xml.js create mode 100644 apps/website/src/pages/rss.xml.ts (limited to 'apps/website/src/pages') diff --git a/apps/website/src/pages/about.astro b/apps/website/src/pages/about.astro index ac51204..5f85a7d 100644 --- a/apps/website/src/pages/about.astro +++ b/apps/website/src/pages/about.astro @@ -7,7 +7,7 @@ import Layout from '@layouts/Layout.astro'; --- - +
Our journey
diff --git a/apps/website/src/pages/blog/index.astro b/apps/website/src/pages/blog/index.astro index 4bccad4..8603764 100644 --- a/apps/website/src/pages/blog/index.astro +++ b/apps/website/src/pages/blog/index.astro @@ -4,9 +4,7 @@ import { getCollection } from 'astro:content'; import FormattedDate from '../../components/base/FormattedDate.astro'; import Layout from '../../layouts/Layout.astro'; -const posts = (await getCollection('blog')).sort( - (a, b) => a.data.pubDate.valueOf() - b.data.pubDate.valueOf(), -); +const posts = await getCollection('blog'); --- @@ -16,10 +14,10 @@ const posts = (await getCollection('blog')).sort( posts.map(post => (
  • - +

    {post.data.title}

    - +

  • diff --git a/apps/website/src/pages/branding.astro b/apps/website/src/pages/branding.astro index e367f3b..4b41edd 100644 --- a/apps/website/src/pages/branding.astro +++ b/apps/website/src/pages/branding.astro @@ -12,7 +12,7 @@ function formatModName(name: string): string { } --- - +
    diff --git a/apps/website/src/pages/contact.astro b/apps/website/src/pages/contact.astro index aac214d..53a6a81 100644 --- a/apps/website/src/pages/contact.astro +++ b/apps/website/src/pages/contact.astro @@ -8,7 +8,7 @@ import Layout from '@layouts/Layout.astro'; --- - +
    Feeling social? Come chat with us
    diff --git a/apps/website/src/pages/index.astro b/apps/website/src/pages/index.astro index 14e59de..c2835ac 100644 --- a/apps/website/src/pages/index.astro +++ b/apps/website/src/pages/index.astro @@ -8,7 +8,7 @@ import Icon from '@components/icons/Icon.astro'; import configConst from '@config'; import Layout from '@layouts/Layout.astro'; --- - +
    +
    diff --git a/apps/website/src/pages/legal/privacy.astro b/apps/website/src/pages/legal/privacy.astro index d3940f2..61fbdff 100644 --- a/apps/website/src/pages/legal/privacy.astro +++ b/apps/website/src/pages/legal/privacy.astro @@ -10,7 +10,7 @@ This will be updated in the future, if necessary. `.trim(); --- - +
    diff --git a/apps/website/src/pages/legal/security.astro b/apps/website/src/pages/legal/security.astro index a80d3f9..0bbf50e 100644 --- a/apps/website/src/pages/legal/security.astro +++ b/apps/website/src/pages/legal/security.astro @@ -10,7 +10,7 @@ This will be updated in the future, if necessary. `.trim(); --- - +
    diff --git a/apps/website/src/pages/legal/terms.astro b/apps/website/src/pages/legal/terms.astro index 6ed2009..e894d76 100644 --- a/apps/website/src/pages/legal/terms.astro +++ b/apps/website/src/pages/legal/terms.astro @@ -10,7 +10,7 @@ This will be updated in the future, if necessary. `.trim(); --- - +
    diff --git a/apps/website/src/pages/mods.astro b/apps/website/src/pages/mods.astro index ae1002c..adde3d7 100644 --- a/apps/website/src/pages/mods.astro +++ b/apps/website/src/pages/mods.astro @@ -14,7 +14,7 @@ const modrinthType = configConst.socials.modrinth.type; const modrinthUrl = `https://modrinth.com/${modrinthType}/${modrinthId}`; --- - +
    diff --git a/apps/website/src/pages/oss.astro b/apps/website/src/pages/oss.astro index a54d929..b7b2715 100644 --- a/apps/website/src/pages/oss.astro +++ b/apps/website/src/pages/oss.astro @@ -39,7 +39,7 @@ const rightCodeBlock = leftCodeBlock; --- - +
    diff --git a/apps/website/src/pages/projects/oneconfig/download.astro b/apps/website/src/pages/projects/oneconfig/download.astro index b8aee51..07279ba 100644 --- a/apps/website/src/pages/projects/oneconfig/download.astro +++ b/apps/website/src/pages/projects/oneconfig/download.astro @@ -7,7 +7,7 @@ import configConst from '@config'; import Layout from '@layouts/Layout.astro'; --- - +
    diff --git a/apps/website/src/pages/projects/oneconfig/index.astro b/apps/website/src/pages/projects/oneconfig/index.astro index e8283f3..ed018cd 100644 --- a/apps/website/src/pages/projects/oneconfig/index.astro +++ b/apps/website/src/pages/projects/oneconfig/index.astro @@ -13,7 +13,7 @@ import { Code } from 'astro:components'; --- - +
    diff --git a/apps/website/src/pages/rss.xml.js b/apps/website/src/pages/rss.xml.js deleted file mode 100644 index fe05755..0000000 --- a/apps/website/src/pages/rss.xml.js +++ /dev/null @@ -1,16 +0,0 @@ -import rss from '@astrojs/rss'; -import { getCollection } from 'astro:content'; - -export async function GET(context) { - const posts = await getCollection('blog'); - - return rss({ - title: 'Polyfrost Blog', - description: 'Recieve Polyfrost updates here', - site: context.site, - items: posts.map(post => ({ - ...post.data, - link: `/blog/${post.slug}/`, - })), - }); -} diff --git a/apps/website/src/pages/rss.xml.ts b/apps/website/src/pages/rss.xml.ts new file mode 100644 index 0000000..db8cfff --- /dev/null +++ b/apps/website/src/pages/rss.xml.ts @@ -0,0 +1,30 @@ +import rss from '@astrojs/rss'; +import { getCollection } from 'astro:content'; +import type { APIRoute } from 'astro'; + +function sortPosts(a: { data: { publishDate: Date } }, b: { data: { publishDate: Date } }) { + return Number(b.data.publishDate) - Number(a.data.publishDate); +} + +function formatDate(date: Date) { + date.setUTCHours(0); + return date; +} + +export const GET: APIRoute = async (context) => { + const unsortedPosts = [...(await getCollection('blog'))]; + const posts = unsortedPosts.sort((a, b) => sortPosts(a, b)); + + return rss({ + title: 'Polyfrost Blog', + description: 'Recieve Polyfrost updates here', + site: context.site!.href, + items: posts.map(post => ({ + ...post.data, + title: post.data.title, + description: post.data.description, + pubDate: formatDate(post.data.publishDate), + link: `/blog/${post.slug}/`, + })), + }); +}; -- cgit