From a56e326a57fa72fe6a34513f49956e6d1b0087b7 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Fri, 21 Oct 2022 23:51:14 +0100 Subject: [PATCH] fix(daily-email): remove newlines in slugs Fix page not found error when adding a permalink in this format: ```yaml --- permalink: > archive/2022/10/20/cherry-picking-commits-is-an-anti-pattern ``` This causes a newline character to be added to the end of the permalink, and causes the previous code to not be able to match the slug for the filename based on the `permalink` value within the front matter. --- website/src/pages/archive/[...slug].astro | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/website/src/pages/archive/[...slug].astro b/website/src/pages/archive/[...slug].astro index e96242f0..73bc6b30 100644 --- a/website/src/pages/archive/[...slug].astro +++ b/website/src/pages/archive/[...slug].astro @@ -5,14 +5,18 @@ import Layout from '../../layouts/DailyEmailLayout.astro' export async function getStaticPaths() { const emails = await Astro.glob('../../daily-emails/*.md') - return emails.map(email => ({ - params: { - slug: email.frontmatter.permalink.replace('archive/', ''), - }, - props: { - email, + return emails.map(email => { + return { + params: { + slug: email.frontmatter.permalink + .replace('archive/', '') + .replace('\n', ''), + }, + props: { + email, + } } - })) + }) } const { Content } = Astro.props.email