fix: re-add page metadata (#1776)

This commit is contained in:
Owarie
2025-11-17 22:47:14 +08:00
committed by GitHub
parent 5a6ce1c4d3
commit 8c51c5b933

View File

@@ -124,6 +124,22 @@ export default async function (eleventyConfig) {
eleventyConfig.addFilter('stripExtension', string => path.parse(string + '').name);
eleventyConfig.addFilter('stripPrefix', content => content.replace(/^wa-/, ''));
eleventyConfig.addFilter('uniqueId', (_value, length = 8) => nanoid(length));
eleventyConfig.addGlobalData('eleventyComputed', {
// Page title with smart + default site name formatting
pageTitle: data => composePageTitle(data.title),
// Open Graph title with smart + default site name formatting
ogTitle: data => composePageTitle(data.ogTitle || data.title),
ogDescription: data => data.ogDescription || data.description,
ogImage: data => data.ogImage || siteMetadata.image,
ogUrl: data => {
if (data.ogUrl) return data.ogUrl;
const url = data.page?.url || '';
return url ? `${siteMetadata.url}${url}` : siteMetadata.url;
},
ogType: data => data.ogType || 'website',
});
// Trims whitespace and pipes from the start and end of a string. Useful for CEM types, which can be pipe-delimited.
// With Prettier 3, this means a leading pipe will exist be present when the line wraps.
eleventyConfig.addFilter('trimPipes', content => {