Skip to content

Commit

Permalink
🐛 Undefined config in metadata (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanc1 authored Apr 19, 2024
1 parent 9810bf7 commit 36282f2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
6 changes: 6 additions & 0 deletions .changeset/curly-bananas-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@myst-theme/article': patch
'@myst-theme/book': patch
---

Bug in page frontmatter being undefined
14 changes: 6 additions & 8 deletions themes/article/app/routes/$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,18 @@ export const meta: V2_MetaFunction = ({ data, matches, location }) => {
const config: SiteManifest = data.config;
const project: ManifestProject = data.project;
const page: PageLoader['frontmatter'] = data.page.frontmatter;

const siteTitle = config?.title ?? project?.title ?? '';
return getMetaTagsForArticle({
origin: '',
url: location.pathname,
title: page.title
? `${page.title} - ${config?.title ?? project.title}`
: `${config?.title ?? project.title}`,
description: page.description ?? project.description ?? config.description ?? undefined,
title: page?.title ? `${page.title}${siteTitle ? ` - ${siteTitle}` : ''}` : siteTitle,
description: page?.description ?? project?.description ?? config?.description ?? undefined,
image:
(page.thumbnailOptimized || page.thumbnail) ??
(project.thumbnailOptimized || project.thumbnail) ??
(page?.thumbnailOptimized || page?.thumbnail) ??
(project?.thumbnailOptimized || project?.thumbnail) ??
undefined,
twitter: config?.options?.twitter,
keywords: page.keywords ?? project.keywords ?? config.keywords ?? [],
keywords: page?.keywords ?? project?.keywords ?? config?.keywords ?? [],
});
};

Expand Down
14 changes: 7 additions & 7 deletions themes/book/app/routes/$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ export const meta: V2_MetaFunction = ({ data, matches, location }) => {
const project: ManifestProject = data.project;
const page: PageLoader['frontmatter'] = data.page.frontmatter;

const siteTitle = config?.title ?? project?.title ?? '';

return getMetaTagsForArticle({
origin: '',
url: location.pathname,
title: page.title
? `${page.title} - ${config?.title ?? project.title}`
: `${config?.title ?? project.title}`,
description: page.description ?? project.description ?? config.description ?? undefined,
title: page?.title ? `${page.title}${siteTitle ? ` - ${siteTitle}` : ''}` : siteTitle,
description: page?.description ?? project?.description ?? config?.description ?? undefined,
image:
(page.thumbnailOptimized || page.thumbnail) ??
(project.thumbnailOptimized || project.thumbnail) ??
(page?.thumbnailOptimized || page?.thumbnail) ??
(project?.thumbnailOptimized || project?.thumbnail) ??
undefined,
twitter: config?.options?.twitter,
keywords: page.keywords ?? project.keywords ?? config.keywords ?? [],
keywords: page?.keywords ?? project?.keywords ?? config?.keywords ?? [],
});
};

Expand Down

0 comments on commit 36282f2

Please sign in to comment.