Something went wrong. Try again.
Browser extension: detect and subscribe to standard.site publications on ATProto
Something went wrong. Try again.
3.3 kB · 83 lines
Astro
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384---import "../styles/global.css";import PostHog from "../components/PostHog.astro";import sequoia from "../../sequoia.json";
interface Props { title: string; description: string; /** "article" for a post, so unfurlers stop calling it a site. */ ogType?: "website" | "article"; /** AT-URI of the record this page was rendered from, if it has one. */ atUri?: string;}
const { title, description, ogType = "website", atUri } = Astro.props;
// The publication this site is. Read from the config that also fills// public/.well-known/site.standard.publication, so the tag and the endpoint a// verifier checks it against cannot drift. Before `sequoia init` runs the// config carries a placeholder, and a tag resolving to nothing is worse than// no tag — the same rule the document link below follows.const publication = /^at:\/\/[^/]+\/site\.standard\.publication\/[^/]+$/.test( sequoia.publicationUri,) ? sequoia.publicationUri : undefined;
// Unfurl crawlers resolve nothing relative, so these must be absolute.const canonical = new URL(Astro.url.pathname, Astro.site);const card = new URL("/og.png", Astro.site);---
<!doctype html><html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>{title}</title> <meta name="description" content={description} /> <link rel="canonical" href={canonical} /> { /* Every page says which publication it belongs to, so a reader that already has the page does not have to probe the origin to find out — and a reader that only probes still gets the same answer from the well-known. */ } {publication && <link rel="site.standard.publication" href={publication} />} { /* The canonical link's ATProto counterpart. Only a page with a record carries it: a verifier resolves the href, so an empty one is worse than a missing tag. */ } {atUri && <link rel="site.standard.document" href={atUri} />} <meta property="og:type" content={ogType} /> <meta property="og:url" content={canonical} /> <meta property="og:title" content={title} /> <meta property="og:description" content={description} /> <meta property="og:image" content={card} /> <meta property="og:image:width" content="1200" /> <meta property="og:image:height" content="630" /> <meta property="og:image:alt" content="The logo and wordmark for substandard.blog" /> {/* Twitter falls back to og:* for everything but the card type. */} <meta name="twitter:card" content="summary_large_image" /> { /* Feed autodiscovery, on every page: a subscribe button asks whatever address it was handed, not just /posts. */ } <link rel="alternate" type="application/atom+xml" title="substandard updates" href="/atom.xml" /> <link rel="icon" type="image/svg+xml" href="/favicon.svg" /> <link rel="icon" type="image/png" sizes="32x32" href="/icons/icon32.png" /> <link rel="apple-touch-icon" href="/icons/icon180.png" /> {/* Production builds only, so dev servers don't pollute analytics. */} {import.meta.env.PROD && <PostHog />} </head> <body> <slot /> </body></html>