diff --git a/src/lib/external-references.ts b/src/lib/external-references.ts index 640cde85..7cb70528 100644 --- a/src/lib/external-references.ts +++ b/src/lib/external-references.ts @@ -37,5 +37,8 @@ export const getAllExternalReferences = async () => { export const getAllExternalReferencesByTag = async (tag: string) => { const refs = await getAllExternalReferences(); - return refs.filter((article) => [...article.frontmatter.tags].includes(tag)); + return refs.filter((article) => { + const tags = article.frontmatter?.tags ?? []; + return tags.includes(tag); + }); }; diff --git a/src/lib/newsletters.ts b/src/lib/newsletters.ts index 45a359ab..2ad45433 100644 --- a/src/lib/newsletters.ts +++ b/src/lib/newsletters.ts @@ -32,5 +32,8 @@ export const getAllNewsletters = async () => { export const getAllNewslettersByTag = async (tag: string) => { const refs = await getAllNewsletters(); - return refs.filter((article) => [...article.frontmatter.tags].includes(tag)); + return refs.filter((article) => { + const tags = article.frontmatter?.tags ?? []; + return tags.includes(tag); + }); };