--- 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; --- {title} {keywords.length > 0 && ( )} {jsonExtra && ( )}