fix(tags): Set consistent titles for tags with description pages

Right now for some tag `my-tag` a tag page with title `Tag: my-tag` is
generated.
However if you create a page `tags/my-tag.md` to add a description the
page will have the title `my-tag` by default.

Set the tag page title to have the `Tag: ` prefix if the tag page does
not have a custom title for consistency between tags with and without
descriptions.
This commit is contained in:
Anton Bulakh 2024-12-24 02:03:09 +02:00
parent a582505daf
commit 2f7bcbd502
No known key found for this signature in database
GPG Key ID: 071FE3E324DD7333

View File

@ -105,6 +105,9 @@ export const TagPage: QuartzEmitterPlugin<Partial<TagPageOptions>> = (userOpts)
const tag = slug.slice("tags/".length) const tag = slug.slice("tags/".length)
if (tags.has(tag)) { if (tags.has(tag)) {
tagDescriptions[tag] = [tree, file] tagDescriptions[tag] = [tree, file]
if (file.data.frontmatter?.title === tag) {
file.data.frontmatter.title = `${i18n(cfg.locale).pages.tagContent.tag}: ${tag}`
}
} }
} }
} }