Skip to content

Commit a3fa8b1

Browse files
committed
centralize global json-ld in custom head
GEO Optimization: move global schema generation out of Starlight config head entries and into a dedicated Head component override. What changed: - Added `src/components/Head.astro` that composes Starlight default head and appends one `application/ld+json` script. - Kept schema parity for Organization/WebSite/Book and switched Organization `@id` to the canonical `swmansion.com` domain. - Updated `astro.config.ts` to register `components.Head` and removed the inline JSON-LD `head` script entry. - Added AGENTS guidance to assume `Astro.site` is always defined in config. Why: - Keeps `astro.config.ts` focused on configuration, not schema object construction. - Creates a stable base for upcoming page-level JSON-LD work while preserving existing global graph behavior. Manual testing: - Ran `bun lint` (`prettier --write . && astro check`) successfully. - Ran `bun run build` successfully earlier in this thread and confirmed generated HTML still contains the global JSON-LD graph. Special considerations: - Commit intentionally includes only staged files from this thread. - Leaves untracked `GEO.md` untouched.
1 parent 7f4e55b commit a3fa8b1

File tree

3 files changed

+60
-47
lines changed

3 files changed

+60
-47
lines changed

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
- you may be running in parallel with other agents; cooperate to avoid conflicts, but avoid committing changes made by others
66
- run `bun lint` to format code and run linters (including `astro check`); there are no tests
77
- ignore any backward compatibility - break stuff everywhere if needed
8+
- assume `Astro.site` is always defined in `astro.config.ts`; do not add defensive fallbacks or runtime guards for it

astro.config.ts

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,6 @@ const site = "https://agentic-engineering.swmansion.com/";
55
const repo = `https://github.com/software-mansion/agentic-engineering/`;
66
const defaultOgImage = `${site}og-default.png`;
77

8-
const globalJsonLd = JSON.stringify({
9-
"@context": "https://schema.org",
10-
"@graph": [
11-
{
12-
"@type": "Organization",
13-
"@id": `${site}#organization`,
14-
name: "Software Mansion",
15-
url: "https://swmansion.com/",
16-
logo: {
17-
"@type": "ImageObject",
18-
url: `${site}swm-logo.png`,
19-
},
20-
},
21-
{
22-
"@type": "WebSite",
23-
"@id": `${site}#website`,
24-
url: site,
25-
name: "Software Mansion Agentic Engineering Guide",
26-
inLanguage: "en",
27-
publisher: {
28-
"@id": `${site}#organization`,
29-
},
30-
},
31-
{
32-
"@type": "Book",
33-
"@id": `${site}#book`,
34-
name: "Software Mansion Agentic Engineering Guide",
35-
description:
36-
"Practical guidance for setting up and scaling agentic engineering workflows in real software projects.",
37-
url: site,
38-
inLanguage: "en",
39-
image: defaultOgImage,
40-
publisher: { "@id": `${site}#organization` },
41-
author: [
42-
{ "@type": "Person", name: "Marek Kaput" },
43-
{ "@type": "Person", name: "Jakub Kosmydel" },
44-
{ "@type": "Person", name: "Adam Grzybowski" },
45-
],
46-
},
47-
],
48-
});
49-
508
// https://astro.build/config
519
export default defineConfig({
5210
site,
@@ -102,6 +60,7 @@ export default defineConfig({
10260
},
10361
],
10462
components: {
63+
Head: "./src/components/Head.astro",
10564
Footer: "./src/components/Footer.astro",
10665
},
10766
editLink: {
@@ -129,11 +88,6 @@ export default defineConfig({
12988
tag: "meta",
13089
attrs: { name: "twitter:creator", content: "@swmansion" },
13190
},
132-
{
133-
tag: "script",
134-
attrs: { type: "application/ld+json" },
135-
content: globalJsonLd,
136-
},
13791
],
13892
}),
13993
],

src/components/Head.astro

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
import Default from "@astrojs/starlight/components/Head.astro";
3+
4+
const { lang, siteTitle } = Astro.locals.starlightRoute;
5+
const organizationId = "https://swmansion.com/#organization";
6+
const websiteId = new URL("#website", Astro.site);
7+
const bookId = new URL("#book", Astro.site);
8+
const defaultOgImage = new URL("og-default.png", Astro.site);
9+
10+
const globalJsonLd = {
11+
"@context": "https://schema.org",
12+
"@graph": [
13+
{
14+
"@type": "Organization",
15+
"@id": organizationId,
16+
name: "Software Mansion",
17+
url: "https://swmansion.com/",
18+
logo: {
19+
"@type": "ImageObject",
20+
url: new URL("swm-logo.png", Astro.site),
21+
},
22+
},
23+
{
24+
"@type": "WebSite",
25+
"@id": websiteId,
26+
url: Astro.site,
27+
name: siteTitle,
28+
inLanguage: lang,
29+
publisher: {
30+
"@id": organizationId,
31+
},
32+
},
33+
{
34+
"@type": "Book",
35+
"@id": bookId,
36+
name: siteTitle,
37+
description:
38+
"Practical guidance for setting up and scaling agentic engineering workflows in real software projects.",
39+
url: Astro.site,
40+
inLanguage: lang,
41+
image: defaultOgImage,
42+
publisher: { "@id": organizationId },
43+
author: [
44+
{ "@type": "Person", name: "Marek Kaput" },
45+
{ "@type": "Person", name: "Jakub Kosmydel" },
46+
{ "@type": "Person", name: "Adam Grzybowski" },
47+
],
48+
},
49+
],
50+
};
51+
---
52+
53+
<Default />
54+
<script
55+
type="application/ld+json"
56+
is:inline
57+
set:html={JSON.stringify(globalJsonLd)}
58+
/>

0 commit comments

Comments
 (0)