@ninjainfosys/site-kit 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +99 -2
  2. package/bin/site-kit.mjs +24 -0
  3. package/package.json +40 -4
  4. package/src/components/blog/Pager.astro +60 -0
  5. package/src/components/blog/PostCard.astro +53 -0
  6. package/src/components/blog/PostList.astro +21 -0
  7. package/src/components/blog/Story.astro +63 -0
  8. package/src/components/blog/Topics.astro +23 -0
  9. package/src/components/seo/Seo.astro +46 -0
  10. package/src/components/site/CtaBand.astro +21 -0
  11. package/src/components/site/DashainPopup.astro +324 -0
  12. package/src/components/site/Faq.astro +37 -0
  13. package/src/components/site/Footer.astro +66 -0
  14. package/src/components/site/Header.astro +311 -0
  15. package/src/components/site/Related.astro +44 -0
  16. package/src/config.ts +56 -0
  17. package/src/contract.ts +181 -0
  18. package/src/integration.d.mts +4 -0
  19. package/src/integration.mjs +96 -0
  20. package/src/layouts/Base.astro +65 -0
  21. package/src/lib/blog-schema.ts +60 -0
  22. package/src/lib/blog.ts +64 -0
  23. package/src/lib/glossary-types.ts +25 -0
  24. package/src/lib/glossary.ts +21 -0
  25. package/src/lib/posts.ts +22 -0
  26. package/src/lib/rehype-figures.mjs +25 -0
  27. package/src/lib/seo.ts +176 -0
  28. package/src/pages/blog/[slug].astro +274 -0
  29. package/src/pages/blog/index.astro +111 -0
  30. package/src/pages/blog/page/[page].astro +32 -0
  31. package/src/pages/blog/tag/[tag].astro +38 -0
  32. package/src/pages/glossary/[slug].astro +125 -0
  33. package/src/pages/glossary/index.astro +51 -0
  34. package/src/pages/llms.txt.ts +25 -0
  35. package/src/pages/og/[...slug].png.ts +61 -0
  36. package/src/pages/rss.xml.ts +23 -0
  37. package/src/scripts/a11y.mjs +38 -0
  38. package/src/scripts/check-credits.mjs +31 -0
  39. package/src/scripts/check-site.mjs +198 -0
  40. package/src/scripts/commons.mjs +106 -0
  41. package/src/scripts/config.mjs +19 -0
  42. package/src/scripts/indexnow.mjs +25 -0
  43. package/src/scripts/redirects.mjs +55 -0
  44. package/src/scripts/sitemap.mjs +173 -0
  45. package/src/styles/base.css +164 -0
  46. package/src/styles/blog-serif.css +2 -0
  47. package/src/styles/motion.css +20 -0
  48. package/src/virtual.d.ts +4 -0
@@ -0,0 +1,274 @@
1
+ ---
2
+ import ChevronDown from '@lucide/astro/icons/chevron-down';
3
+ import { render } from 'astro:content';
4
+ import blogImages from 'virtual:site-kit/blog-images';
5
+ import { Image, getImage } from 'astro:assets';
6
+ import { LICENCES } from '../../lib/blog-schema';
7
+ import Base from '@site/layouts/Base.astro';
8
+ import CtaBand from '../../components/site/CtaBand.astro';
9
+ import Related from '../../components/site/Related.astro';
10
+ import { productsForTags, solutionsForTags } from '@site/data/links';
11
+ import { coverFor, fmtDate, posts, readMinutes, type Post } from '../../lib/posts';
12
+ import { related, tagLabel } from '../../lib/blog';
13
+ import { articleJsonLd, breadcrumbJsonLd, faqJsonLd } from '../../lib/seo';
14
+ import { kit } from '../../config';
15
+
16
+ export async function getStaticPaths() {
17
+ const all = await posts();
18
+ return all.map((post) => ({ params: { slug: post.id }, props: { post, all } }));
19
+ }
20
+ const { post, all } = Astro.props as { post: Post; all: Post[] };
21
+ const { Content, headings } = await render(post);
22
+ // Contents list from the post's own H2s, shown when there are enough to need one.
23
+ const toc = headings.filter((h) => h.depth === 2);
24
+ const hasToc = toc.length >= 4;
25
+ const minutes = readMinutes(post);
26
+ const d = post.data;
27
+ const path = `/blog/${post.id}`;
28
+ // The post's first topic is its section in the breadcrumb trail.
29
+ const topic = d.tags.find((t) => t !== 'guides') ?? d.tags[0];
30
+ // Share image: the cover cropped to 1200x630, else the generated card.
31
+ const image = d.cover ? (await getImage({ src: d.cover, width: 1200, height: 630, fit: 'cover', format: 'jpg' })).src : coverFor(post);
32
+ const credits = d.credits.filter((c) => !('own' in c));
33
+ // Every credited image as an ImageObject with its licence, so search engines
34
+ // show the right credit (and the Licensable badge) in image results.
35
+ const files = blogImages as Record<string, { default: ImageMetadata }>;
36
+ const imageObjects = await Promise.all(
37
+ d.credits.map(async (c) => {
38
+ const mod = files[`/src/assets/blog/${post.id}/${c.file}`];
39
+ if (!mod) return null;
40
+ const url = new URL((await getImage({ src: mod.default, width: 1200, format: 'jpg' })).src, Astro.site).href;
41
+ return 'own' in c
42
+ ? { '@context': 'https://schema.org', '@type': 'ImageObject', contentUrl: url, creditText: kit.blog.imageCredit, creator: { '@type': 'Organization', name: kit.blog.imageCredit }, copyrightNotice: kit.blog.imageCredit }
43
+ : { '@context': 'https://schema.org', '@type': 'ImageObject', contentUrl: url, name: c.title, creditText: `${c.author}, ${c.licence}`, creator: { '@type': 'Person', name: c.author, ...(c.authorUrl ? { url: c.authorUrl } : {}) }, license: LICENCES[c.licence], acquireLicensePage: c.source };
44
+ }),
45
+ ).then((xs) => xs.filter((x) => x !== null));
46
+ const more = related(all.map((p) => ({ ...p, data: { ...p.data, draft: false } })), { ...post, data: { ...d, draft: false } }) as Post[];
47
+ const pillar = all.find((p) => p.data.pillar && p.id !== post.id && p.data.tags.some((t) => d.tags.includes(t)));
48
+ const next = [...(pillar ? [pillar] : []), ...more.filter((m) => m.id !== pillar?.id)];
49
+ const readNext = (next.length ? next : all.filter((p) => p.id !== post.id)).slice(0, 3);
50
+ ---
51
+ <Base
52
+ title={d.title}
53
+ description={d.description}
54
+ path={path}
55
+ type="article"
56
+ image={image}
57
+ imageAlt={d.coverAlt ?? d.imageAlt}
58
+ published={d.date}
59
+ modified={d.updated ?? d.date}
60
+ noindex={d.draft}
61
+ jsonLd={[
62
+ articleJsonLd({ slug: post.id, title: d.title, description: d.description, date: d.date, updated: d.updated, image, tags: d.tags, words: (post.body ?? '').split(/\s+/).filter(Boolean).length }),
63
+ breadcrumbJsonLd([{ name: kit.blog.label, path: '/blog' }, ...(topic ? [{ name: tagLabel(topic), path: `/blog/tag/${topic}` }] : []), { name: d.title, path }]),
64
+ ...((d.faq ?? []).length ? [faqJsonLd(d.faq ?? [])] : []),
65
+ ...imageObjects,
66
+ ]}
67
+ >
68
+ <article class="post">
69
+ <header class="wrap head">
70
+ <nav class="crumbs" aria-label="Breadcrumb" data-enter>
71
+ <ol>
72
+ <li><a href="/blog">{kit.blog.label}</a></li>
73
+ {topic && <li><a href={`/blog/tag/${topic}`}>{tagLabel(topic)}</a></li>}
74
+ </ol>
75
+ </nav>
76
+ <h1 class="title" data-enter>{d.title}</h1>
77
+ <p class="meta" data-enter>
78
+ <time datetime={d.date.toISOString()}>{fmtDate(d.date)}</time>
79
+ {d.updated && <> · Updated <time datetime={d.updated.toISOString()}>{fmtDate(d.updated)}</time></>}
80
+ <> · {minutes} min read</>
81
+ {d.draft && <span class="draft"> · Draft, not published</span>}
82
+ </p>
83
+ {d.cover && (
84
+ <figure class="cover" data-enter>
85
+ <Image src={d.cover} alt={d.coverAlt ?? ''} widths={[480, 800, 1200, 1600]} sizes="(max-width: 1200px) 100vw, 1200px" loading="eager" fetchpriority="high" />
86
+ </figure>
87
+ )}
88
+ </header>
89
+ <div class="wrap grid">
90
+ <div class="col">
91
+ {d.takeaways.length > 0 && (
92
+ <section class="takeaways" aria-labelledby="tk-h" data-enter>
93
+ <h2 id="tk-h">Key takeaways</h2>
94
+ <ul>{d.takeaways.map((t) => <li>{t}</li>)}</ul>
95
+ </section>
96
+ )}
97
+ {hasToc && (
98
+ <details class="toc-inline no-print" data-enter>
99
+ <summary>On this page<ChevronDown size={18} stroke-width={2} aria-hidden="true" /></summary>
100
+ <ol>{toc.map((h) => <li><a href={`#${h.slug}`}>{h.text}</a></li>)}</ol>
101
+ </details>
102
+ )}
103
+ <div class="prose body" data-enter>
104
+ <Content />
105
+ {(d.faq ?? []).length > 0 && (
106
+ <section class="post-faq" aria-labelledby="faq-h">
107
+ <h2 id="faq-h">Questions people ask</h2>
108
+ {(d.faq ?? []).map((f) => <><h3>{f.q}</h3><p>{f.a}</p></>)}
109
+ </section>
110
+ )}
111
+ </div>
112
+ {credits.length > 0 && (
113
+ <section class="credits" aria-labelledby="credits-h">
114
+ <h2 id="credits-h">Image credits</h2>
115
+ <ul>
116
+ {credits.map((c) => 'title' in c && (
117
+ <li>
118
+ “<a href={c.source} rel="nofollow noopener">{c.title}</a>” by {c.authorUrl ? <a href={c.authorUrl} rel="nofollow noopener">{c.author}</a> : c.author},
119
+ {' '}<a href={LICENCES[c.licence]} rel="license nofollow noopener">{c.licence}</a>{c.changes && <>. {c.changes}</>}.
120
+ </li>
121
+ ))}
122
+ </ul>
123
+ </section>
124
+ )}
125
+ {readNext.length > 0 && (
126
+ <nav class="next no-print" aria-labelledby="next-h">
127
+ <h2 id="next-h">Read next</h2>
128
+ <ul>
129
+ {readNext.map((p) => (
130
+ <li><a href={`/blog/${p.id}`}><span>{p.data.title}</span><time datetime={p.data.date.toISOString()}>{fmtDate(p.data.date)}</time></a></li>
131
+ ))}
132
+ </ul>
133
+ </nav>
134
+ )}
135
+ </div>
136
+ {hasToc && (
137
+ <aside class="rail no-print" aria-labelledby="rail-h">
138
+ <nav class="toc" aria-labelledby="rail-h">
139
+ <h2 id="rail-h">On this page</h2>
140
+ <ol>{toc.map((h) => <li><a href={`#${h.slug}`} data-toc={h.slug}>{h.text}</a></li>)}</ol>
141
+ </nav>
142
+ </aside>
143
+ )}
144
+ </div>
145
+ </article>
146
+
147
+ <Related groups={[
148
+ { h: 'Products in this article', items: productsForTags(d.tags) },
149
+ { h: 'Industries', items: solutionsForTags(d.tags) },
150
+ { h: 'More insights', items: all.filter((x) => x.id !== post.id && !readNext.some((r) => r.id === x.id)).slice(0, 3).map((x) => ({ href: `/blog/${x.id}`, label: x.data.title })) },
151
+ ]} />
152
+ <CtaBand />
153
+ </Base>
154
+
155
+ <script>
156
+ // Wide tables scroll inside their own box instead of the page.
157
+ document.querySelectorAll('.prose table').forEach((t) => {
158
+ const box = document.createElement('div');
159
+ box.className = 'table-scroll';
160
+ t.replaceWith(box);
161
+ box.append(t);
162
+ });
163
+
164
+ // The side contents list marks the section being read.
165
+ const links = new Map([...document.querySelectorAll<HTMLAnchorElement>('[data-toc]')].map((a) => [a.dataset.toc!, a]));
166
+ if (links.size) {
167
+ const seen = new Set<string>();
168
+ const mark = () => {
169
+ const order = [...links.keys()];
170
+ const current = order.filter((id) => seen.has(id)).at(0) ?? null;
171
+ links.forEach((a, id) => a.toggleAttribute('aria-current', id === current));
172
+ };
173
+ const io = new IntersectionObserver((entries) => {
174
+ entries.forEach((e) => (e.isIntersecting ? seen.add(e.target.id) : seen.delete(e.target.id)));
175
+ mark();
176
+ }, { rootMargin: '-96px 0px -60% 0px' });
177
+ links.forEach((_, id) => { const h = document.getElementById(id); if (h) io.observe(h); });
178
+ }
179
+ // Closing the mobile contents list after a jump keeps the text in view.
180
+ document.querySelectorAll('.toc-inline a').forEach((a) => a.addEventListener('click', () => a.closest('details')?.removeAttribute('open')));
181
+ </script>
182
+
183
+
184
+ <style>
185
+ /* Reading layout: one text column (about 68 characters a line) and, on wide
186
+ screens, a sticky "On this page" rail. Phones get the same order with a
187
+ tap-to-open contents list. */
188
+ .post { padding-block: var(--space-6) var(--space-9); }
189
+ /* Breadcrumb trail: section and topic, the title follows as the heading. */
190
+ .crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); list-style: none; margin: 0; padding: 0; font-size: 14px; }
191
+ .crumbs li { display: inline-flex; align-items: center; gap: var(--space-2); }
192
+ .crumbs li + li::before { content: '›'; color: var(--ink-muted); }
193
+ .crumbs a { display: inline-flex; align-items: center; min-height: 32px; color: var(--ink-muted); text-decoration: none; }
194
+ .crumbs a:hover { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
195
+ .crumbs li:last-child a { color: var(--link); font-weight: 500; }
196
+ .title { margin: var(--space-4) 0 var(--space-3); max-width: 26ch; font-weight: 600; font-size: clamp(1.875rem, 1.3rem + 2.4vw, 3.25rem); line-height: 1.12; text-wrap: balance; overflow-wrap: anywhere; }
197
+ .meta { margin: 0 0 var(--space-6); font-size: 15px; color: var(--ink-muted); }
198
+ .draft { color: var(--error); }
199
+ /* Header, cover and text share the page's left edge; the cover spans text and rail. */
200
+ .cover { margin: 0 0 var(--space-7); }
201
+ .cover :global(img) { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius-panel); background: var(--surface); }
202
+
203
+ .grid { display: grid; grid-template-columns: minmax(0, 680px) 240px; justify-content: space-between; gap: var(--space-9); }
204
+ .col { min-width: 0; }
205
+
206
+ /* Key takeaways: a light list between two rules, no box. */
207
+ .takeaways { margin: 0 0 var(--space-6); padding: var(--space-5) 0; border-block: 1px solid var(--line); }
208
+ .takeaways h2 { margin: 0 0 var(--space-3); font-size: 1rem; line-height: 1.3; }
209
+ .takeaways ul { margin: 0; padding-left: 1.2em; display: grid; gap: var(--space-2); }
210
+ .takeaways li { font-size: 1.0625rem; line-height: 1.6; padding-left: 0.2em; }
211
+ .takeaways li::marker { color: var(--lime); font-size: 1.1em; }
212
+
213
+ /* Body text: serif, 18px, comfortable but not airy. */
214
+ .body { max-width: none; font-size: 1.0625rem; line-height: 1.7; }
215
+ .body :global(p), .body :global(ul), .body :global(ol) { margin: 0 0 1.1em; }
216
+ .body :global(li + li) { margin-top: 0.35em; }
217
+ .body :global(h2) { font-weight: 600; font-size: 1.5rem; line-height: 1.25; margin: 1.8em 0 0.6em; scroll-margin-top: 104px; }
218
+ .body :global(h3) { font-weight: 600; font-size: 1.1875rem; line-height: 1.3; margin: 1.5em 0 0.4em; scroll-margin-top: 104px; }
219
+ .body :global(table) { display: block; overflow-x: auto; }
220
+ .body :global(figure) { margin: 1.6em 0; }
221
+ .body :global(figure img), .body :global(img) { display: block; width: 100%; height: auto; margin: 0; border-radius: var(--radius-panel); background: var(--surface); }
222
+ .body :global(figcaption) { margin-top: var(--space-2); font-size: 14px; line-height: 1.45; color: var(--ink-muted); }
223
+
224
+ /* Contents on the right, sticky, current section in ink. */
225
+ .rail { position: relative; }
226
+ .toc { position: sticky; top: 104px; max-height: calc(100vh - 128px); overflow-y: auto; }
227
+ .toc h2, .toc-inline summary { font-size: 14px; font-weight: 600; color: var(--ink); margin: 0 0 var(--space-3); }
228
+ .toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
229
+ .toc a { display: block; margin-left: -1px; padding: 7px 0 7px var(--space-4); border-left: 2px solid transparent; color: var(--ink-muted); font-size: 14px; line-height: 1.45; text-decoration: none; transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease); }
230
+ .toc a:hover { color: var(--ink); }
231
+ .toc a[aria-current] { color: var(--ink); font-weight: 500; border-left-color: var(--lime); }
232
+
233
+ /* Tablet and phone: no rail; contents fold into a list under the takeaways. */
234
+ .toc-inline { display: none; margin: 0 0 var(--space-6); border: 1px solid var(--line); border-radius: var(--radius-panel); }
235
+ .toc-inline summary { display: flex; align-items: center; justify-content: space-between; min-height: 48px; margin: 0; padding: 0 var(--space-4); cursor: pointer; list-style: none; }
236
+ .toc-inline summary::-webkit-details-marker { display: none; }
237
+ .toc-inline summary :global(svg) { transition: transform var(--fast) var(--ease); }
238
+ .toc-inline[open] summary :global(svg) { transform: rotate(180deg); }
239
+ .toc-inline ol { list-style: none; margin: 0; padding: 0 var(--space-4) var(--space-2); }
240
+ .toc-inline li + li { border-top: 1px solid var(--line); }
241
+ .toc-inline a { display: flex; align-items: center; min-height: 44px; padding-block: var(--space-2); color: var(--ink); font-size: 15px; line-height: 1.4; text-decoration: none; }
242
+ .toc-inline a:hover { color: var(--link); }
243
+
244
+ .credits { margin-top: var(--space-7); padding-top: var(--space-5); border-top: 1px solid var(--line); font-size: 14px; line-height: 1.5; color: var(--ink-muted); }
245
+ .credits h2 { font-size: 15px; margin: 0 0 var(--space-2); color: var(--ink); }
246
+ .credits ul { margin: 0; padding-left: var(--space-5); }
247
+ .credits li + li { margin-top: var(--space-1); }
248
+ .credits a { color: var(--ink-muted); }
249
+
250
+ .next { margin-top: var(--space-8); }
251
+ .next h2 { font-size: 1.125rem; margin: 0 0 var(--space-3); }
252
+ .next ul { list-style: none; margin: 0; padding: 0; }
253
+ .next a { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4) 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; }
254
+ .next li:last-child a { border-bottom: 1px solid var(--line); }
255
+ .next span { font-weight: 500; line-height: 1.35; transition: color var(--fast) var(--ease); }
256
+ .next a:hover span { color: var(--link); }
257
+ .next time { font-size: 14px; color: var(--ink-muted); }
258
+
259
+ @media (max-width: 1099px) {
260
+ .grid { grid-template-columns: minmax(0, 680px); gap: 0; }
261
+ .rail { display: none; }
262
+ .toc-inline { display: block; }
263
+ }
264
+ @media (max-width: 599px) {
265
+ .post { padding-top: var(--space-4); }
266
+ .cover { margin: 0 calc(-1 * var(--gutter)) var(--space-6); }
267
+ .cover :global(img) { border-radius: 0; aspect-ratio: 3 / 2; }
268
+ .body { font-size: 1rem; line-height: 1.7; }
269
+ .body :global(h2) { font-size: 1.3125rem; }
270
+ .body :global(figure) { margin: 1.4em calc(-1 * var(--gutter)); }
271
+ .body :global(figure img) { border-radius: 0; }
272
+ .body :global(figcaption) { padding-inline: var(--gutter); }
273
+ }
274
+ </style>
@@ -0,0 +1,111 @@
1
+ ---
2
+ // The blog front, laid out like a news front: the top story big with three
3
+ // beside it, the latest stories as photo cards, then a section per topic and a
4
+ // numbered "Start here" list of the guides to read first.
5
+ import Base from '@site/layouts/Base.astro';
6
+ import Story from '../../components/blog/Story.astro';
7
+ import Topics from '../../components/blog/Topics.astro';
8
+ import Pager from '../../components/blog/Pager.astro';
9
+ import { posts } from '../../lib/posts';
10
+ import { PAGE_SIZE, allTags, byTag, tagLabel } from '../../lib/blog';
11
+ import { breadcrumbJsonLd } from '../../lib/seo';
12
+ import { kit } from '../../config';
13
+
14
+ const all = await posts();
15
+ const tags = allTags(all.map((p) => ({ ...p, data: { ...p.data, draft: false } })));
16
+ const last = Math.max(1, Math.ceil(all.length / PAGE_SIZE));
17
+ const [lead, ...rest] = all;
18
+ const side = rest.slice(0, 3);
19
+ const latest = rest.slice(3, 11);
20
+ const guides = all.filter((p) => p.data.pillar).concat(all.filter((p) => !p.data.pillar && p.data.tags.includes('guides'))).slice(0, 5);
21
+ // Topic sections: the busiest topics with at least three stories, guides aside.
22
+ const sections = tags
23
+ .filter((t) => t !== 'guides')
24
+ .map((t) => ({ tag: t, items: byTag(all, t) }))
25
+ .filter((s) => s.items.length >= 3)
26
+ .sort((a, b) => b.items.length - a.items.length)
27
+ .slice(0, 3);
28
+ ---
29
+ <Base title={kit.blog.label} description={kit.blog.description} path="/blog" jsonLd={[breadcrumbJsonLd([{ name: kit.blog.label, path: '/blog' }])]}>
30
+ <section class="front">
31
+ <div class="wrap">
32
+ <h1>{kit.blog.label}</h1>
33
+ <Topics tags={tags} />
34
+
35
+ {lead ? (
36
+ <>
37
+ <div class="top" data-enter>
38
+ <Story post={lead} size="top" level="h2" eager />
39
+ {side.length > 0 && <div class="side-list">{side.map((p) => <Story post={p} size="side" />)}</div>}
40
+ </div>
41
+
42
+ {latest.length > 0 && (
43
+ <section class="block" aria-labelledby="latest-h">
44
+ <h2 id="latest-h" class="block-h">Latest</h2>
45
+ <div class="cards">{latest.map((p) => <Story post={p} size="grid" />)}</div>
46
+ </section>
47
+ )}
48
+
49
+ <div class="split">
50
+ <div class="topics-col">
51
+ {sections.map((s) => (
52
+ <section class="block" aria-labelledby={`s-${s.tag}`}>
53
+ <div class="block-head">
54
+ <h2 id={`s-${s.tag}`} class="block-h">{tagLabel(s.tag)}</h2>
55
+ <a class="all" href={`/blog/tag/${s.tag}`}>See all {s.items.length}</a>
56
+ </div>
57
+ <div class="topic">
58
+ <Story post={s.items[0]} size="grid" />
59
+ <div>{s.items.slice(1, 5).map((p) => <Story post={p} size="list" />)}</div>
60
+ </div>
61
+ </section>
62
+ ))}
63
+ </div>
64
+ {guides.length > 0 && (
65
+ <aside class="block start" aria-labelledby="start-h">
66
+ <h2 id="start-h" class="block-h">Start here</h2>
67
+ {guides.map((p, i) => <Story post={p} size="list" n={i + 1} />)}
68
+ </aside>
69
+ )}
70
+ </div>
71
+
72
+ <Pager current={1} last={last} />
73
+ </>
74
+ ) : <p class="muted">The first posts are on their way.</p>}
75
+ </div>
76
+ </section>
77
+ </Base>
78
+
79
+ <style>
80
+ .front { padding-block: var(--space-7) var(--space-9); }
81
+ h1 { margin: 0 0 var(--space-5); font-size: clamp(2rem, 1.5rem + 2vw, 3rem); }
82
+ .front :global(.topics) { margin-bottom: var(--space-7); }
83
+
84
+ .top { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--space-7); align-items: start; }
85
+ .side-list > :global(.story:first-child) { border-top: 0; padding-top: 0; }
86
+
87
+ .block { margin-top: var(--space-9); }
88
+ .block-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); border-top: 2px solid var(--ink); padding-top: var(--space-3); margin-bottom: var(--space-5); }
89
+ .block-h { margin: 0; font-size: 1.375rem; }
90
+ .block > .block-h { border-top: 2px solid var(--ink); padding-top: var(--space-3); margin-bottom: var(--space-5); }
91
+ .all { font-size: 15px; font-weight: 500; color: var(--link); white-space: nowrap; }
92
+
93
+ .cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-7) var(--space-6); }
94
+ .split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--space-8); align-items: start; }
95
+ .topic { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-6); }
96
+ .topic > div > :global(.story:first-child) { border-top: 0; padding-top: 0; }
97
+ .start { position: sticky; top: 104px; }
98
+
99
+ @media (max-width: 1099px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
100
+ @media (max-width: 899px) {
101
+ .top, .split { grid-template-columns: 1fr; }
102
+ .side-list > :global(.story:first-child) { border-top: 1px solid var(--line); padding-top: var(--space-4); }
103
+ .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
104
+ .start { position: static; }
105
+ }
106
+ @media (max-width: 599px) {
107
+ .front { padding-top: var(--space-5); }
108
+ .block { margin-top: var(--space-8); }
109
+ .cards, .topic { grid-template-columns: 1fr; gap: var(--space-6); }
110
+ }
111
+ </style>
@@ -0,0 +1,32 @@
1
+ ---
2
+ import Base from '@site/layouts/Base.astro';
3
+ import PostList from '../../../components/blog/PostList.astro';
4
+ import Pager from '../../../components/blog/Pager.astro';
5
+ import { posts, type Post } from '../../../lib/posts';
6
+ import { PAGE_SIZE, pagePath } from '../../../lib/blog';
7
+ import { kit } from '../../../config';
8
+
9
+ export async function getStaticPaths() {
10
+ const all = await posts();
11
+ const last = Math.ceil(all.length / PAGE_SIZE);
12
+ // Page 1 is /blog itself; this route only builds pages 2 and later.
13
+ return Array.from({ length: Math.max(0, last - 1) }, (_, i) => {
14
+ const n = i + 2;
15
+ return { params: { page: String(n) }, props: { n, last, items: all.slice((n - 1) * PAGE_SIZE, n * PAGE_SIZE) } };
16
+ });
17
+ }
18
+ const { n, last, items } = Astro.props as { n: number; last: number; items: Post[] };
19
+ ---
20
+ <Base title={`${kit.blog.label}, page ${n}`} description={kit.blog.pageDescription(n, last)} path={pagePath(n)}>
21
+ <section class="section blog-serif">
22
+ <div class="wrap">
23
+ <h1>{kit.blog.label}, page {n}</h1>
24
+ <PostList items={items} />
25
+ <Pager current={n} last={last} />
26
+ </div>
27
+ </section>
28
+ </Base>
29
+
30
+ <style>
31
+ h1 { margin-bottom: var(--space-6); }
32
+ </style>
@@ -0,0 +1,38 @@
1
+ ---
2
+ import Base from '@site/layouts/Base.astro';
3
+ import PostList from '../../../components/blog/PostList.astro';
4
+ import Topics from '../../../components/blog/Topics.astro';
5
+ import { posts, type Post } from '../../../lib/posts';
6
+ import { tagLabel } from '../../../lib/blog';
7
+ import { breadcrumbJsonLd } from '../../../lib/seo';
8
+ import { kit } from '../../../config';
9
+
10
+ export async function getStaticPaths() {
11
+ const all = await posts();
12
+ const tags = [...new Set(all.flatMap((p) => p.data.tags))].sort();
13
+ return tags.map((tag) => ({ params: { tag }, props: { tag, tags, items: all.filter((p) => p.data.tags.includes(tag)) } }));
14
+ }
15
+ const { tag, tags, items } = Astro.props as { tag: string; tags: string[]; items: Post[] };
16
+ const label = tagLabel(tag);
17
+ const path = `/blog/tag/${tag}`;
18
+ // Topics with fewer than three posts stay out of search until they fill up.
19
+ ---
20
+ <Base
21
+ title={`${label} articles`}
22
+ description={kit.blog.tagDescription(label)}
23
+ path={path}
24
+ noindex={items.length < 3}
25
+ jsonLd={[breadcrumbJsonLd([{ name: kit.blog.label, path: '/blog' }, { name: label, path }])]}
26
+ >
27
+ <section class="section blog-serif">
28
+ <div class="wrap">
29
+ <h1>{label}</h1>
30
+ <Topics tags={tags} current={tag} />
31
+ <PostList items={items} />
32
+ </div>
33
+ </section>
34
+ </Base>
35
+
36
+ <style>
37
+ h1 { margin-bottom: var(--space-6); }
38
+ </style>
@@ -0,0 +1,125 @@
1
+ ---
2
+ import Base from '@site/layouts/Base.astro';
3
+ import Related from '../../components/site/Related.astro';
4
+ import CtaBand from '../../components/site/CtaBand.astro';
5
+ import ArrowLeft from '@lucide/astro/icons/arrow-left';
6
+ import { glossary, termBySlug, type Term } from '../../lib/glossary';
7
+ import { productLink, productTags } from '@site/data/links';
8
+ import { posts } from '../../lib/posts';
9
+ import { breadcrumbJsonLd, definedTermJsonLd, faqJsonLd, termArticleJsonLd } from '../../lib/seo';
10
+
11
+ export function getStaticPaths() {
12
+ return glossary.map((t) => ({ params: { slug: t.slug }, props: { t } }));
13
+ }
14
+ const { t } = Astro.props as { t: Term };
15
+ const path = `/glossary/${t.slug}`;
16
+ const heading = t.full ? `What is ${t.term} (${t.full})?` : `What is ${/^[A-Z]{2,}/.test(t.term) ? t.term : `a ${t.term.toLowerCase()}`}?`;
17
+ const related = t.related.map(termBySlug).filter((x): x is Term => !!x);
18
+ const product = t.product ? productLink(t.product) : null;
19
+ const guides = t.product
20
+ ? (await posts()).filter((x) => !x.data.draft && x.data.tags.some((g) => productTags[t.product!]?.includes(g))).slice(0, 3)
21
+ : [];
22
+ const sections = t.sections ?? [];
23
+ const faq = [{ q: heading, a: t.short }, ...(t.faq ?? [])];
24
+ const title = t.title ?? `${t.term}${t.full ? ` (${t.full})` : ''}: meaning and how it works`;
25
+ const description = t.description ?? (t.short.length <= 160 ? t.short : `${t.short.slice(0, 157).replace(/\s+\S*$/, '')}…`);
26
+ const strip = (x: string) => x.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1');
27
+ const words = [t.short, ...t.body, ...sections.flatMap((x) => [x.h, ...x.p, ...(x.list ?? [])]), ...(t.faq ?? []).flatMap((f) => [f.q, f.a])]
28
+ .map(strip).join(' ').split(/\s+/).length;
29
+ // Copy is ours; escape it, then turn [text](/path) into internal links.
30
+ const esc = (x: string) => x.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
31
+ // A link to a glossary term that is not live yet renders as plain text.
32
+ const md = (x: string) => esc(x).replace(/\[([^\]]+)\]\((\/[^)\s]*)\)/g, (_, text, href) =>
33
+ href.startsWith('/glossary/') && !termBySlug(href.slice(10).split('#')[0]) ? text : `<a href="${href}">${text}</a>`);
34
+ ---
35
+ <Base
36
+ title={title}
37
+ description={description}
38
+ path={path}
39
+ jsonLd={[
40
+ definedTermJsonLd(t),
41
+ ...(sections.length && t.updated ? [termArticleJsonLd({ slug: t.slug, term: t.term, title, description, published: t.published ?? t.updated, updated: t.updated, sections, words })] : []),
42
+ faqJsonLd(faq.map((f) => ({ q: f.q, a: strip(f.a) }))),
43
+ breadcrumbJsonLd([{ name: 'Glossary', path: '/glossary' }, { name: t.term, path }]),
44
+ ]}
45
+ >
46
+ <article class="term">
47
+ <div class="wrap">
48
+ <div class="col">
49
+ <a class="back" href="/glossary" data-enter><ArrowLeft size={18} stroke-width={2} aria-hidden="true" /> Glossary</a>
50
+ <h1 data-enter>{heading}</h1>
51
+ <p class="def" data-enter><dfn>{t.term}</dfn>{t.short.slice(t.term.length)}</p>
52
+ <div class="prose body" data-enter>
53
+ {t.body.map((p) => <p set:html={md(p)} />)}
54
+ </div>
55
+ {sections.length > 0 && (
56
+ <nav class="toc" aria-label="On this page" data-enter>
57
+ <span class="see-h">On this page</span>
58
+ <ol>{sections.map((x) => <li><a href={`#${x.id}`}>{x.h}</a></li>)}</ol>
59
+ </nav>
60
+ )}
61
+ {sections.map((x) => (
62
+ <section class="prose body sec" id={x.id}>
63
+ <h2>{x.h}</h2>
64
+ {x.p.map((p) => <p set:html={md(p)} />)}
65
+ {x.list && <ul>{x.list.map((li) => <li set:html={md(li)} />)}</ul>}
66
+ </section>
67
+ ))}
68
+ {t.faq && t.faq.length > 0 && (
69
+ <section class="prose body sec" id="faq">
70
+ <h2>Questions people ask about {/^[A-Z]{2,}/.test(t.term) ? t.term : t.term.toLowerCase()}s</h2>
71
+ {t.faq.map((f) => (
72
+ <>
73
+ <h3>{f.q}</h3>
74
+ <p set:html={md(f.a)} />
75
+ </>
76
+ ))}
77
+ </section>
78
+ )}
79
+ {t.updated && <p class="upd">Updated <time datetime={t.updated}>{new Date(t.updated).toLocaleDateString('en-GB', { day: 'numeric', month: 'long', year: 'numeric' })}</time></p>}
80
+ {related.length > 0 && (
81
+ <nav class="see" aria-label="Related terms" data-enter>
82
+ <span class="see-h">Related terms</span>
83
+ <ul>{related.map((r) => <li><a href={`/glossary/${r.slug}`}>{r.term}</a></li>)}</ul>
84
+ </nav>
85
+ )}
86
+ </div>
87
+ </div>
88
+ </article>
89
+
90
+ <Related groups={[
91
+ { h: 'Where this matters', items: product ? [product] : [] },
92
+ { h: 'Guides', items: guides.map((g) => ({ href: `/blog/${g.id}`, label: g.data.title })) },
93
+ { h: 'More terms', items: glossary.filter((x) => x.slug !== t.slug && !t.related.includes(x.slug)).slice(0, 4).map((x) => ({ href: `/glossary/${x.slug}`, label: x.term })) },
94
+ ]} />
95
+ <CtaBand />
96
+ </Base>
97
+
98
+ <style>
99
+ .term { padding-block: var(--space-8) var(--space-9); }
100
+ .col { max-width: 720px; }
101
+ .back { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; color: var(--ink-muted); text-decoration: none; font-size: 16px; }
102
+ .back:hover { color: var(--ink); }
103
+ h1 { margin: var(--space-5) 0 var(--space-5); font-family: 'Source Serif 4 Variable', 'Serif Fallback', Georgia, serif; font-weight: 600; font-size: clamp(2rem, 1.5rem + 2vw, 3rem); line-height: 1.12; }
104
+ /* The quotable one-line answer, set apart from the explanation. */
105
+ .def { margin: 0 0 var(--space-6); padding: var(--space-5) var(--space-6); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); font-size: 1.1875rem; line-height: 1.5; }
106
+ dfn { font-style: normal; font-weight: 600; }
107
+ .body { max-width: none; font-family: 'Source Serif 4 Variable', 'Serif Fallback', Georgia, serif; font-size: 1.125rem; line-height: 1.5; }
108
+ .body p { margin: 0 0 var(--space-4); }
109
+ .toc { margin: var(--space-6) 0; padding: var(--space-5) var(--space-6); border: 1px solid var(--line); border-radius: var(--radius-panel); }
110
+ .toc ol { margin: var(--space-3) 0 0; padding-left: var(--space-5); font-size: 16px; line-height: 1.5; }
111
+ .toc li { margin: var(--space-1) 0; }
112
+ .toc a { color: var(--link); }
113
+ .sec { margin-top: var(--space-7); scroll-margin-top: var(--space-8); }
114
+ .sec h2 { margin: 0 0 var(--space-4); font-weight: 600; font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); line-height: 1.12; }
115
+ .sec h3 { margin: var(--space-5) 0 var(--space-2); font-size: 1.25rem; font-weight: 600; line-height: 1.3; }
116
+ .sec ul { margin: 0 0 var(--space-4); padding-left: var(--space-5); }
117
+ .sec li { margin: 0 0 var(--space-2); }
118
+ .body a { color: var(--link); }
119
+ .upd { margin-top: var(--space-6); font-size: 15px; color: var(--ink-muted); }
120
+ .see { margin-top: var(--space-6); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
121
+ .see-h { font-size: 15px; font-weight: 600; color: var(--ink-muted); }
122
+ .see ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
123
+ .see a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-control); color: var(--ink); text-decoration: none; font-size: 15px; transition: border-color var(--fast) var(--ease), color var(--fast) var(--ease); }
124
+ .see a:hover { border-color: var(--brand); color: var(--link); }
125
+ </style>
@@ -0,0 +1,51 @@
1
+ ---
2
+ import Base from '@site/layouts/Base.astro';
3
+ import ArrowRight from '@lucide/astro/icons/arrow-right';
4
+ import { glossary } from '../../lib/glossary';
5
+ import { kit } from '../../config';
6
+ import { breadcrumbJsonLd, definedTermSetJsonLd } from '../../lib/seo';
7
+
8
+ const terms = [...glossary].sort((a, b) => a.term.localeCompare(b.term));
9
+ ---
10
+ <Base
11
+ title={kit.glossary.indexTitle}
12
+ description={kit.glossary.indexDescription}
13
+ path="/glossary"
14
+ jsonLd={[definedTermSetJsonLd(terms), breadcrumbJsonLd([{ name: 'Glossary', path: '/glossary' }])]}
15
+ >
16
+ <section class="section blog-serif">
17
+ <div class="wrap">
18
+ <h1 data-enter>Glossary</h1>
19
+ <ul class="terms">
20
+ {terms.map((t, i) => (
21
+ <li data-enter style={`--d:${Math.min(i + 1, 8)}`}>
22
+ <a href={`/glossary/${t.slug}`}>
23
+ <span class="name">{t.term}{t.full && <span class="full"> · {t.full}</span>}</span>
24
+ <span class="short">{t.short}</span>
25
+ <ArrowRight class="go" size={18} stroke-width={2} aria-hidden="true" />
26
+ </a>
27
+ </li>
28
+ ))}
29
+ </ul>
30
+ </div>
31
+ </section>
32
+ </Base>
33
+
34
+ <style>
35
+ h1 { margin-bottom: var(--space-7); }
36
+ .terms { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--line); }
37
+ .terms a {
38
+ display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr) auto; gap: var(--space-6); align-items: baseline;
39
+ padding: var(--space-5) 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none;
40
+ }
41
+ .name { font-family: 'Source Serif 4 Variable', 'Serif Fallback', Georgia, serif; font-size: 1.375rem; font-weight: 600; transition: color var(--fast) var(--ease); }
42
+ .full { display: block; font-family: var(--font-sans); font-size: 14px; font-weight: 400; color: var(--ink-muted); margin-top: 2px; }
43
+ .short { font-size: 16px; line-height: 1.5; color: var(--ink-muted); }
44
+ .terms :global(.go) { color: var(--ink-muted); transition: transform var(--fast) var(--ease), color var(--fast) var(--ease); }
45
+ .terms a:hover .name { color: var(--link); }
46
+ .terms a:hover :global(.go) { transform: translateX(4px); color: var(--link); }
47
+ @media (max-width: 767px) {
48
+ .terms a { grid-template-columns: 1fr auto; gap: var(--space-2) var(--space-4); }
49
+ .short { grid-column: 1 / -1; grid-row: 2; }
50
+ }
51
+ </style>