2026-08-12 01:11:32 +08:00
|
|
|
---
|
|
|
|
|
import { siteConfig } from '@/site.config';
|
2026-08-30 20:57:39 +08:00
|
|
|
import { getWebmentionEndpoint } from '@/lib/webmentions';
|
2026-08-12 01:11:32 +08:00
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
title?: string;
|
|
|
|
|
description?: string;
|
|
|
|
|
image?: string;
|
|
|
|
|
type?: 'website' | 'article';
|
|
|
|
|
noindex?: boolean;
|
2026-08-30 20:57:39 +08:00
|
|
|
webmention?: boolean;
|
2026-08-12 01:11:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
title,
|
|
|
|
|
description = siteConfig.site.description,
|
|
|
|
|
image,
|
|
|
|
|
type = 'website',
|
2026-08-30 20:57:39 +08:00
|
|
|
noindex = false,
|
|
|
|
|
webmention = false
|
2026-08-12 01:11:32 +08:00
|
|
|
} = Astro.props;
|
|
|
|
|
const pageTitle = title ? `${title} - ${siteConfig.site.title}` : siteConfig.site.title;
|
|
|
|
|
const canonical = new URL(Astro.url.pathname, siteConfig.site.url);
|
|
|
|
|
const imageUrl = image ? new URL(image, siteConfig.site.url) : undefined;
|
2026-08-30 20:57:39 +08:00
|
|
|
const webmentionEndpoint = webmention && siteConfig.webmentions.enabled && siteConfig.webmentions.endpoint.trim()
|
|
|
|
|
? getWebmentionEndpoint(siteConfig.webmentions.endpoint, 'receive')
|
|
|
|
|
: undefined;
|
2026-08-12 01:11:32 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
|
|
<title>{pageTitle}</title>
|
|
|
|
|
<meta name="description" content={description} />
|
|
|
|
|
<link rel="canonical" href={canonical} />
|
2026-08-30 20:57:39 +08:00
|
|
|
{webmentionEndpoint && <link rel="webmention" href={webmentionEndpoint} />}
|
2026-08-12 01:11:32 +08:00
|
|
|
<meta property="og:type" content={type} />
|
|
|
|
|
<meta property="og:title" content={pageTitle} />
|
|
|
|
|
<meta property="og:description" content={description} />
|
|
|
|
|
<meta property="og:url" content={canonical} />
|
|
|
|
|
<meta property="og:site_name" content={siteConfig.site.title} />
|
|
|
|
|
{imageUrl && <meta property="og:image" content={imageUrl} />}
|
|
|
|
|
<meta name="twitter:card" content={imageUrl ? 'summary_large_image' : 'summary'} />
|
|
|
|
|
{noindex && <meta name="robots" content="noindex, nofollow" />}
|