interplane.Get Omega
Read in your language

sovereign-intelligence

Front door to Drake Stapleton's sovereign stack.

Brought by drakestapleton

branch main Branches Tags History

sovereign-intelligence / docs / archive / drakestapleton.com-old / src / lib / usePageMeta.ts

128 lines · 4685 bytes Raw Blame History
1import { useEffect } from "react";
2import pageMetadata from "../../site-metadata.json";
3
4type Meta = { title: string; description: string };
5type PageMetaInput = string | (Meta & { path: string; robots?: string });
6
7const metadata = pageMetadata as Record<string, Meta>;
8const siteUrl = "https://www.drakestapleton.com";
9
10function structuredData(path: string, title: string, description: string) {
11 const canonical = `${siteUrl}${path}`;
12 const person = {
13 "@type": "Person",
14 "@id": `${siteUrl}/#person`,
15 name: "Drake Stapleton",
16 jobTitle: "AI Architect & Operator",
17 description: "Freedom Fighter, AI Architect & Operator documenting projects, research, and the life behind the work.",
18 url: `${siteUrl}/`,
19 image: `${siteUrl}/og.png?v=20260820`,
20 sameAs: ["https://github.com/aien-dev"],
21 alumniOf: {
22 "@type": "CollegeOrUniversity",
23 name: "Western Kentucky University",
24 url: "https://www.wku.edu/",
25 },
26 subjectOf: [
27 {
28 "@type": "Thesis",
29 name: "Master of Science in Chemistry thesis",
30 datePublished: "2018",
31 url: "https://digitalcommons.wku.edu/theses/2101/",
32 },
33 {
34 "@type": "ScholarlyArticle",
35 name: "2019 peer-reviewed nanomaterials paper",
36 datePublished: "2019",
37 url: "https://pubmed.ncbi.nlm.nih.gov/30931213/",
38 },
39 ],
40 };
41 const graph = path === "/"
42 ? [
43 { "@type": "WebSite", "@id": `${siteUrl}/#website`, name: "Drake Stapleton", url: `${siteUrl}/` },
44 person,
45 {
46 "@type": "FAQPage",
47 "@id": `${siteUrl}/#faq`,
48 mainEntity: [
49 {
50 "@type": "Question",
51 name: "Why did Drake Stapleton build this site?",
52 acceptedAnswer: {
53 "@type": "Answer",
54 text: "This site documents Drake Stapleton's projects, the work behind them, and the life that shaped them.",
55 },
56 },
57 {
58 "@type": "Question",
59 name: "What work does Drake Stapleton do?",
60 acceptedAnswer: {
61 "@type": "Answer",
62 text: "I design, operate, and audit production orchestration, GPU systems, and verifiable AI architecture.",
63 },
64 },
65 {
66 "@type": "Question",
67 name: "What is Atlas?",
68 acceptedAnswer: {
69 "@type": "Answer",
70 text: "Atlas is Drake Stapleton's personal R&D program in accountable AI architecture, continuity, model training, and orchestration.",
71 },
72 },
73 ],
74 },
75 ]
76 : [
77 {
78 "@type": "WebPage",
79 "@id": `${canonical}#webpage`,
80 name: title,
81 description,
82 url: canonical,
83 isPartOf: { "@id": `${siteUrl}/#website` },
84 about: { "@id": `${siteUrl}/#person` },
85 },
86 person,
87 ];
88 return { "@context": "https://schema.org", "@graph": graph };
89}
90
91export function usePageMeta(input: PageMetaInput, robots?: string) {
92 const path = typeof input === "string" ? input : input.path;
93 const shared = typeof input === "string" ? metadata[path] : input;
94 const title = shared?.title;
95 const description = shared?.description;
96 const robotPolicy = robots || (typeof input === "string" ? undefined : input.robots);
97
98 if (!title || !description) throw new Error(`Missing page metadata for ${path}`);
99
100 useEffect(() => {
101 document.title = title;
102 const url = `${siteUrl}${path}`;
103 const setMeta = (selector: string, content: string) => {
104 document.querySelector(selector)?.setAttribute("content", content);
105 };
106
107 setMeta('meta[name="description"]', description);
108 setMeta('meta[property="og:title"]', title);
109 setMeta('meta[property="og:description"]', description);
110 setMeta('meta[property="og:url"]', url);
111 setMeta('meta[name="twitter:title"]', title);
112 setMeta('meta[name="twitter:description"]', description);
113 setMeta(
114 'meta[name="robots"]',
115 robotPolicy || (import.meta.env.MODE === "portfolio" ? "index, follow" : "noindex, nofollow, noarchive"),
116 );
117 document.querySelector('link[rel="canonical"]')?.setAttribute("href", url);
118
119 let script = document.querySelector<HTMLScriptElement>('#structured-data');
120 if (!script) {
121 script = document.createElement("script");
122 script.id = "structured-data";
123 script.type = "application/ld+json";
124 document.head.append(script);
125 }
126 script.textContent = JSON.stringify(structuredData(path, title, description));
127 }, [title, description, path, robotPolicy]);
128}