103 lines
2.7 KiB
Plaintext
103 lines
2.7 KiB
Plaintext
---
|
|
import yaml from "js-yaml";
|
|
import fs from "fs";
|
|
|
|
const seo = Astro.props.seo ?? {};
|
|
const globalSeo = yaml.load(
|
|
fs.readFileSync("./src/content/home/seo.yaml", "utf8")
|
|
);
|
|
|
|
const { site, company } = globalSeo;
|
|
|
|
const page = seo.page ?? {};
|
|
|
|
const title = page.title ?? site.name;
|
|
const description = page.description ?? site.description;
|
|
const image = page.image ?? site.logo;
|
|
const canonical = site.url + (page.url ?? "/");
|
|
const keywords = page.keywords ?? [];
|
|
|
|
const extraSchema = page.schema ?? null;
|
|
|
|
// JSON-LD objects
|
|
const schemaWebsite = {
|
|
"@context": "https://schema.org",
|
|
"@type": "WebSite",
|
|
"url": site.url,
|
|
"name": site.name,
|
|
"potentialAction": {
|
|
"@type": "SearchAction",
|
|
"target": `${site.url}/wyszukiwarka?query={search_term_string}`,
|
|
"query-input": "required name=search_term_string"
|
|
}
|
|
};
|
|
|
|
const schemaLocalBusiness = {
|
|
"@context": "https://schema.org",
|
|
"@type": "LocalBusiness",
|
|
"name": company.name,
|
|
"image": site.url + company.logo,
|
|
"telephone": company.phone,
|
|
"email": company.email,
|
|
"address": {
|
|
"@type": "PostalAddress",
|
|
"streetAddress": company.street,
|
|
"addressLocality": company.city,
|
|
"postalCode": company.postal,
|
|
"addressCountry": company.country
|
|
},
|
|
"geo": {
|
|
"@type": "GeoCoordinates",
|
|
"latitude": company.lat,
|
|
"longitude": company.lon
|
|
},
|
|
"url": site.url
|
|
};
|
|
|
|
// JSON strings
|
|
const jsonWebsite = JSON.stringify(schemaWebsite);
|
|
const jsonBusiness = JSON.stringify(schemaLocalBusiness);
|
|
const jsonExtra = extraSchema ? JSON.stringify(extraSchema) : null;
|
|
---
|
|
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
|
|
<title>{title}</title>
|
|
<meta name="description" content={description} />
|
|
|
|
{keywords.length > 0 && (
|
|
<meta name="keywords" content={keywords.join(", ")} />
|
|
)}
|
|
|
|
<link rel="canonical" href={canonical} />
|
|
|
|
<!-- OpenGraph -->
|
|
<meta property="og:type" content="website" />
|
|
<meta property="og:title" content={title} />
|
|
<meta property="og:description" content={description} />
|
|
<meta property="og:url" content={canonical} />
|
|
<meta property="og:site_name" content={site.name} />
|
|
<meta property="og:image" content={image} />
|
|
|
|
<!-- Twitter -->
|
|
<meta name="twitter:card" content="summary_large_image" />
|
|
<meta name="twitter:title" content={title} />
|
|
<meta name="twitter:description" content={description} />
|
|
<meta name="twitter:image" content={image} />
|
|
|
|
<!-- JSON-LD: Website -->
|
|
<script type="application/ld+json" set:html={jsonWebsite}></script>
|
|
|
|
<!-- JSON-LD: LocalBusiness -->
|
|
<script type="application/ld+json" set:html={jsonBusiness}></script>
|
|
|
|
<!-- JSON-LD: Extra schema -->
|
|
{jsonExtra && (
|
|
<script type="application/ld+json" set:html={jsonExtra}></script>
|
|
)}
|
|
|
|
<slot />
|
|
</head>
|