mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 04:09:12 +00:00
fixing page and Open Graph titles for Home view (#1666)
* fixes the redundant 'Web Awesome | Web Awesome' titles * moves logic to `.eleventy.js` * gracefully handles no titles/og titles with `Web Awesome`
This commit is contained in:
@@ -182,8 +182,16 @@ export default async function (eleventyConfig) {
|
||||
// Attach lastUpdatedISO to page data so templates can use {{ lastUpdatedISO }} directly
|
||||
eleventyConfig.addGlobalData('eleventyComputed', {
|
||||
lastUpdatedISO: data => getLastModifiedISO(data.page?.inputPath, data.lastUpdated),
|
||||
// Open Graph metadata with smart defaults
|
||||
ogTitle: data => data.ogTitle || data.title,
|
||||
// Page title with smart + default site name formatting
|
||||
pageTitle: data => {
|
||||
const title = data.title || siteMetadata.name;
|
||||
return title !== siteMetadata.name ? `${title} | ${siteMetadata.name}` : title;
|
||||
},
|
||||
// Open Graph title with smart + default site name formatting
|
||||
ogTitle: data => {
|
||||
const ogTitle = data.ogTitle || data.title || siteMetadata.name;
|
||||
return ogTitle !== siteMetadata.name ? `${ogTitle} | ${siteMetadata.name}` : ogTitle;
|
||||
},
|
||||
ogDescription: data => data.ogDescription || data.description,
|
||||
ogImage: data => data.ogImage || siteMetadata.image,
|
||||
ogUrl: data => {
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
<meta name="description" content="{{ description }}">
|
||||
{% if noindex or unlisted %}<meta name="robots" content="noindex">{% endif %}
|
||||
|
||||
<title>{{ title }} | {{ siteMetadata.name }}</title>
|
||||
<title>{{ pageTitle }}</title>
|
||||
|
||||
{# Skip OG tags for unlisted/noindex pages to prevent social sharing #}
|
||||
{% if not (noindex or unlisted) %}
|
||||
<meta property="og:type" content="{{ ogType }}" />
|
||||
<meta property="og:url" content="{{ ogUrl }}" />
|
||||
<meta property="og:title" content="{{ ogTitle }} | {{ siteMetadata.name }}" />
|
||||
<meta property="og:title" content="{{ ogTitle }}" />
|
||||
<meta property="og:description" content="{{ ogDescription }}" />
|
||||
<meta property="og:image" content="{{ ogImage }}" />
|
||||
<meta property="og:site_name" content="{{ siteMetadata.name }}" />
|
||||
|
||||
Reference in New Issue
Block a user