feat: add structured product metadata
This commit is contained in:
2 files changed
+67
-4
No files matched your search
+36
-3
@@ -3,20 +3,40 @@ import Header from '../components/Header.astro';
|
||||
import Footer from '../components/Footer.astro';
|
||||
import '../styles/global.css';
|
||||
|
||||
type OpenGraphType = 'website' | 'article';
|
||||
type StructuredData = Record<string, unknown>;
|
||||
|
||||
interface Props {
|
||||
title?: string;
|
||||
description?: string;
|
||||
image?: string;
|
||||
ogType?: OpenGraphType;
|
||||
robots?: string;
|
||||
publishedTime?: Date;
|
||||
updatedTime?: Date;
|
||||
author?: string;
|
||||
tags?: string[];
|
||||
structuredData?: StructuredData;
|
||||
}
|
||||
|
||||
const {
|
||||
title = 'Green Tea — A zen, type-safe graph-pipeline HTTP framework',
|
||||
description = 'Green Tea is a graph-pipeline HTTP framework: declare what you need, not the order to build it. Runtime-agnostic, type-safe, calm by design.',
|
||||
image = '/og.png',
|
||||
ogType = 'website',
|
||||
robots = 'index, follow',
|
||||
publishedTime,
|
||||
updatedTime,
|
||||
author,
|
||||
tags,
|
||||
structuredData,
|
||||
} = Astro.props;
|
||||
|
||||
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
|
||||
const ogImageURL = new URL(image, Astro.site);
|
||||
const canonicalURL = new URL(Astro.url.pathname, Astro.site).toString();
|
||||
const ogImageURL = new URL(image, Astro.site).toString();
|
||||
const serializedStructuredData = structuredData
|
||||
? JSON.stringify(structuredData).replace(/</g, '\\u003c')
|
||||
: undefined;
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
@@ -29,13 +49,24 @@ const ogImageURL = new URL(image, Astro.site);
|
||||
|
||||
<title>{title}</title>
|
||||
<meta name="description" content={description} />
|
||||
<meta name="robots" content={robots} />
|
||||
|
||||
<!-- Open Graph -->
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:type" content={ogType} />
|
||||
<meta property="og:url" content={canonicalURL} />
|
||||
<meta property="og:title" content={title} />
|
||||
<meta property="og:description" content={description} />
|
||||
<meta property="og:image" content={ogImageURL} />
|
||||
{
|
||||
ogType === 'article' && (
|
||||
<>
|
||||
{publishedTime && <meta property="article:published_time" content={publishedTime.toISOString()} />}
|
||||
{updatedTime && <meta property="article:modified_time" content={updatedTime.toISOString()} />}
|
||||
{author && <meta property="article:author" content={author} />}
|
||||
{tags?.map((tag) => <meta property="article:tag" content={tag} />)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
<!-- Twitter -->
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
@@ -43,6 +74,8 @@ const ogImageURL = new URL(image, Astro.site);
|
||||
<meta name="twitter:description" content={description} />
|
||||
<meta name="twitter:image" content={ogImageURL} />
|
||||
|
||||
{serializedStructuredData && <script type="application/ld+json" set:html={serializedStructuredData} />}
|
||||
|
||||
<!-- RSS -->
|
||||
<link rel="alternate" type="application/rss+xml" title="Green Tea. Blog" href="/rss.xml" />
|
||||
|
||||
|
||||
+31
-1
@@ -13,9 +13,39 @@ import HonestBeta from '../components/sections/HonestBeta.astro';
|
||||
const title = 'Green Tea — Type-safe graph-pipeline framework for Node, Deno & Bun';
|
||||
const description =
|
||||
'Your API is a graph, not a middleware chain. Declare what each step needs and Green Tea computes the order — one runtime dependency, type-safe, runtime-agnostic, calm by design.';
|
||||
const canonicalURL = new URL('/', Astro.site).toString();
|
||||
const repositoryURL = 'https://github.com/Expressive-Tea/green-tea';
|
||||
const structuredData = {
|
||||
'@context': 'https://schema.org',
|
||||
'@graph': [
|
||||
{
|
||||
'@type': 'WebSite',
|
||||
'@id': `${canonicalURL}#website`,
|
||||
url: canonicalURL,
|
||||
name: 'Green Tea',
|
||||
description,
|
||||
},
|
||||
{
|
||||
'@type': 'SoftwareApplication',
|
||||
'@id': `${canonicalURL}#software`,
|
||||
name: 'Green Tea',
|
||||
description,
|
||||
applicationCategory: 'DeveloperApplication',
|
||||
operatingSystem: 'Cross-platform',
|
||||
url: canonicalURL,
|
||||
codeRepository: repositoryURL,
|
||||
license: `${repositoryURL}/blob/main/LICENSE`,
|
||||
offers: {
|
||||
'@type': 'Offer',
|
||||
price: '0',
|
||||
priceCurrency: 'USD',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
---
|
||||
|
||||
<Base title={title} description={description}>
|
||||
<Base title={title} description={description} structuredData={structuredData}>
|
||||
<Hero />
|
||||
<GraphNotChain />
|
||||
<HowItCompares />
|
||||
|
||||
Reference in new issue
Block a user