@ninjainfosys/site-kit 0.0.0-stage → 0.1.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 (46) 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 +62 -0
  14. package/src/components/site/Header.astro +309 -0
  15. package/src/components/site/Related.astro +44 -0
  16. package/src/config.ts +55 -0
  17. package/src/contract.ts +173 -0
  18. package/src/integration.d.mts +4 -0
  19. package/src/integration.mjs +61 -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 +273 -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 +60 -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 +167 -0
  46. package/src/styles/motion.css +20 -0
@@ -0,0 +1,309 @@
1
+ ---
2
+ import ArrowRight from '@lucide/astro/icons/arrow-right';
3
+ import ChevronDown from '@lucide/astro/icons/chevron-down';
4
+ // Enterprise-style masthead (IBM / TCS / McKinsey pattern): a thin utility
5
+ // strip, a clean main bar, and full-width mega menus that drop below the
6
+ // whole header with columns and one featured item. Content comes from
7
+ // `kit.header` in the site's config/kit.ts.
8
+ import { kit } from '../../config';
9
+
10
+ const { groups, plain, utility, logo, action, mobileLinks, mobileCall, homeLabel } = kit.header;
11
+ const path = Astro.url.pathname.replace(/\.html$/, '');
12
+ const current = (href: string) => (path === href || path.startsWith(`${href}/`) ? 'page' : undefined);
13
+ ---
14
+ <div class="utility">
15
+ <div class="wrap u-row">
16
+ <a href={utility.lead.href} class="u-call">{utility.lead.text}{utility.lead.mono && <span class="mono">{utility.lead.mono}</span>}</a>
17
+ <nav aria-label="Utility" class="u-links">
18
+ {utility.links.map((l, i) => <>{i > 0 && ' '}<a href={l.href}>{l.label}</a></>)}
19
+ </nav>
20
+ </div>
21
+ </div>
22
+
23
+ <header class="site-header">
24
+ <div class="wrap bar">
25
+ <a class="logo" href="/" aria-label={homeLabel}>
26
+ <img src={logo.light} alt={logo.alt} width={logo.width} height={logo.height} class="logo-light" />
27
+ <img src={logo.dark} alt="" width={logo.width} height={logo.height} class="logo-dark" aria-hidden="true" />
28
+ </a>
29
+
30
+ <nav class="nav-wide" aria-label="Main">
31
+ <ul class="top">
32
+ {groups.map((g) => (
33
+ <li>
34
+ <details class="menu" data-menu>
35
+ <summary aria-current={path.startsWith(g.base) ? 'page' : undefined}>{g.label}</summary>
36
+ <div class="mega">
37
+ <div class="wrap mega-grid">
38
+ <ul class="mega-links">
39
+ {g.links.map((l) => (
40
+ <li><a href={l.href} aria-current={current(l.href)}><span class="m-name">{l.label}</span></a></li>
41
+ ))}
42
+ </ul>
43
+ <a class="mega-feature" href={g.feature.href}>
44
+ <span class="f-title">{g.feature.title}</span>
45
+ <span class="f-cta">{g.feature.cta} <span aria-hidden="true"><ArrowRight class="arrow-icon" size={18} stroke-width={2} aria-hidden="true" /></span></span>
46
+ </a>
47
+ </div>
48
+ </div>
49
+ </details>
50
+ </li>
51
+ ))}
52
+ {plain.map((l) => <li><a class="nav-link" href={l.href} aria-current={current(l.href)}>{l.label}</a></li>)}
53
+ </ul>
54
+ </nav>
55
+
56
+ <div class="actions">
57
+ {action.google
58
+ ? <div class="gsi" data-gsi-slot><div class="gsi-btn" data-gsi-button></div><a class="btn btn-secondary gsi-fallback" href={action.href}>{action.label}</a></div>
59
+ : <a class="btn btn-primary" href={action.href}>{action.label}</a>}
60
+ <details class="mobile" data-menu>
61
+ <summary aria-label="Menu"><span class="bars" aria-hidden="true"><i></i></span><span class="mobile-label">Menu</span></summary>
62
+ <nav class="mobile-panel" aria-label="Main">
63
+ <ul class="m-list">
64
+ {groups.map((g) => (
65
+ <li>
66
+ <details class="m-acc" open={path.startsWith(g.base) || undefined}>
67
+ <summary class="m-row">{g.label}<ChevronDown class="m-chev" size={22} stroke-width={2} aria-hidden="true" /></summary>
68
+ <ul class="m-sub">
69
+ {g.links.map((l) => <li><a href={l.href} aria-current={current(l.href)}>{l.label}</a></li>)}
70
+ </ul>
71
+ </details>
72
+ </li>
73
+ ))}
74
+ {plain.map((l) => <li><a class="m-row" href={l.href} aria-current={current(l.href)}>{l.label}</a></li>)}
75
+ </ul>
76
+ <ul class="m-small">
77
+ {mobileLinks.map((l, i) => <>{i > 0 && ' '}<li><a href={l.href}>{l.label}</a></li></>)}
78
+ </ul>
79
+ <div class="mobile-actions">
80
+ <a class="btn btn-secondary" href={mobileCall.href}>{mobileCall.label}</a>
81
+ <a class="btn btn-primary" href={action.href}>{action.label}</a>
82
+ </div>
83
+ </nav>
84
+ </details>
85
+ </div>
86
+ </div>
87
+ </header>
88
+
89
+ <script>
90
+ const header = document.querySelector<HTMLElement>('.site-header')!;
91
+ const menus = Array.from(document.querySelectorAll<HTMLDetailsElement>('[data-menu]'));
92
+ const still = matchMedia('(prefers-reduced-motion: reduce)');
93
+ // Close a desktop menu by rolling it back up before it disappears.
94
+ const close = (m: HTMLDetailsElement) => {
95
+ if (!m.open || m.classList.contains('closing')) return;
96
+ if (still.matches) { m.open = false; return; }
97
+ m.classList.add('closing');
98
+ window.setTimeout(() => { if (m.classList.contains('closing')) { m.classList.remove('closing'); m.open = false; } }, 260);
99
+ };
100
+ const sync = () => header.classList.toggle('menu-open', menus.some((m) => m.open && !m.classList.contains('mobile')));
101
+ document.addEventListener('click', (e) => {
102
+ for (const m of menus) if (m.open && !m.contains(e.target as Node)) close(m);
103
+ });
104
+ document.addEventListener('keydown', (e) => {
105
+ if (e.key !== 'Escape') return;
106
+ for (const m of menus) if (m.open) { close(m); m.querySelector('summary')?.focus(); }
107
+ });
108
+ for (const m of menus) m.addEventListener('toggle', () => {
109
+ if (m.open) header.classList.toggle('switching', menus.some((o) => o !== m && o.open && !o.classList.contains('mobile')));
110
+ if (m.open) for (const o of menus) if (o !== m) { o.classList.remove('closing'); o.open = false; }
111
+ sync();
112
+ });
113
+ // Open on hover with a mouse. A short delay keeps menus from flickering as
114
+ // the pointer crosses the bar; leaving the whole menu closes it.
115
+ if (matchMedia('(hover: hover) and (pointer: fine)').matches) {
116
+ for (const m of menus.filter((x) => !x.classList.contains('mobile'))) {
117
+ let t = 0;
118
+ const li = m.closest('li')!;
119
+ li.addEventListener('pointerenter', () => { clearTimeout(t); if (m.classList.contains('closing')) { m.classList.remove('closing'); return; } t = window.setTimeout(() => { m.open = true; }, 150); });
120
+ li.addEventListener('pointerleave', () => { clearTimeout(t); t = window.setTimeout(() => close(m), 220); });
121
+ // A click on the label while hover-opened should not close it.
122
+ m.querySelector('summary')!.addEventListener('click', (e) => { if (m.open) { e.preventDefault(); } });
123
+ }
124
+ }
125
+
126
+ // The mobile menu opens right under the bar, wherever the bar is.
127
+ const place = () => header.style.setProperty('--header-h', `${Math.round(header.getBoundingClientRect().bottom)}px`);
128
+ for (const m of menus) m.addEventListener('toggle', place);
129
+ // While the mobile sheet is open the page behind it stays put.
130
+ const mobile = menus.find((m) => m.classList.contains('mobile'));
131
+ mobile?.addEventListener('toggle', () => {
132
+ document.documentElement.classList.toggle('menu-locked', mobile.open);
133
+ });
134
+ // The summary toggles natively; route its close through the animation.
135
+ mobile?.querySelector('summary')!.addEventListener('click', (e) => { if (mobile.open) { e.preventDefault(); close(mobile); } });
136
+ addEventListener('resize', place, { passive: true });
137
+ place();
138
+ </script>
139
+
140
+ <style>
141
+ .site-header { position: sticky; top: 0; z-index: 50; background: var(--canvas); border-bottom: 1px solid var(--line); }
142
+ .utility { position: relative; z-index: 51; }
143
+
144
+ .utility { background: var(--stage); color: var(--stage-ink); font-size: 14px; }
145
+ .u-row { display: flex; align-items: center; justify-content: space-between; min-height: 36px; gap: var(--space-4); }
146
+ .utility a { color: var(--stage-ink); text-decoration: none; }
147
+ .utility a:hover { text-decoration: underline; }
148
+ .u-links { display: flex; gap: var(--space-5); }
149
+
150
+ .bar { display: flex; align-items: center; gap: var(--space-7); height: 72px; }
151
+ .logo { flex: none; display: block; }
152
+ .logo img { width: 128px; height: auto; }
153
+ .logo-dark { display: none; }
154
+
155
+ .nav-wide { flex: 1; align-self: stretch; }
156
+ .top { display: flex; gap: var(--space-5); list-style: none; margin: 0; padding: 0; height: 100%; align-items: stretch; }
157
+ .top > li { display: flex; }
158
+ summary { list-style: none; cursor: pointer; }
159
+ summary::-webkit-details-marker { display: none; }
160
+ .nav-link, .menu > summary {
161
+ display: inline-flex; align-items: center; gap: 8px; height: 100%; min-height: 44px;
162
+ color: var(--ink); text-decoration: none; font-size: 16px; font-weight: 500;
163
+ position: relative;
164
+ transition: color var(--fast) var(--ease);
165
+ }
166
+ .nav-link::before, .menu > summary::before {
167
+ content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--brand);
168
+ transform: scaleX(0); transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1); pointer-events: none;
169
+ }
170
+ .menu[open]:not(.closing) > summary::before, .nav-link[aria-current='page']::before, .menu > summary[aria-current='page']::before { transform: scaleX(1); }
171
+ .nav-link:hover, .menu > summary:hover { color: var(--link); }
172
+ .menu[open] > summary, .nav-link[aria-current='page'], .menu > summary[aria-current='page'] { color: var(--link); }
173
+ .menu > summary::after {
174
+ content: ''; width: 6px; height: 6px; margin-top: -3px;
175
+ border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
176
+ transform: rotate(45deg); transition: transform 360ms cubic-bezier(0.22, 1, 0.36, 1);
177
+ }
178
+ .menu[open]:not(.closing) > summary::after { transform: translateY(3px) rotate(-135deg); }
179
+
180
+ /* Full-width mega menu below the whole header. */
181
+ .mega {
182
+ position: absolute; left: 0; right: 0; top: 100%;
183
+ background: var(--canvas); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
184
+ }
185
+ /* Opening from closed: the panel unrolls downward from the bar, then its
186
+ links rise in one after another. Moving between menus keeps the panel
187
+ still and only replays the links. */
188
+ .site-header:not(.switching) .menu[open] .mega { animation: unroll 460ms cubic-bezier(0.22, 1, 0.36, 1); }
189
+ .menu.closing .mega { animation: rollup 260ms cubic-bezier(0.4, 0, 1, 1) forwards !important; }
190
+ .menu.closing .mega-links li, .menu.closing .mega-feature { animation: item-out 180ms ease-in forwards !important; }
191
+ .menu[open] .mega-links li, .menu[open] .mega-feature { animation: item-in 520ms cubic-bezier(0.22, 1, 0.36, 1) both; }
192
+ .menu[open] .mega-links li:nth-child(1) { animation-delay: 80ms; }
193
+ .menu[open] .mega-links li:nth-child(2) { animation-delay: 130ms; }
194
+ .menu[open] .mega-links li:nth-child(3) { animation-delay: 180ms; }
195
+ .menu[open] .mega-links li:nth-child(4) { animation-delay: 230ms; }
196
+ .menu[open] .mega-links li:nth-child(5) { animation-delay: 280ms; }
197
+ .menu[open] .mega-feature { animation-delay: 200ms; }
198
+ @keyframes unroll { from { clip-path: inset(0 0 100% 0); opacity: 0.6; } to { clip-path: inset(0 0 0 0); opacity: 1; } }
199
+ @keyframes rollup { from { clip-path: inset(0 0 0 0); opacity: 1; } to { clip-path: inset(0 0 100% 0); opacity: 0.4; } }
200
+ @keyframes item-out { to { opacity: 0; transform: translateY(-4px); } }
201
+ @keyframes item-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
202
+ .mega-grid { display: grid; grid-template-columns: 1fr 340px; gap: var(--space-8); padding-block: var(--space-7); }
203
+ .mega-links { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-7); }
204
+ .mega-links a { display: block; padding: var(--space-4) 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; }
205
+ .mega-links li:nth-child(-n+2) a { border-top: 0; }
206
+ .m-name { font-size: 17px; font-weight: 600; transition: color var(--fast) var(--ease); }
207
+ .mega-links a:hover .m-name, .mega-links a[aria-current='page'] .m-name { color: var(--link); }
208
+ .mega-feature {
209
+ display: grid; align-content: end; gap: var(--space-2); padding: var(--space-6);
210
+ background: var(--stage); color: var(--stage-ink); border-radius: var(--radius-panel); text-decoration: none; min-height: 180px;
211
+ }
212
+ .f-title { font-size: 1.375rem; font-weight: 600; line-height: 1.25; }
213
+ .f-cta { display: inline-flex; align-items: center; gap: 6px; margin-top: var(--space-3); color: var(--lime); font-weight: 600; }
214
+ .f-cta span { display: inline-flex; transition: transform var(--fast) var(--ease); }
215
+ .mega-feature:hover .f-cta span { display: inline-flex; transform: translateX(4px); transition: transform var(--fast) var(--ease); }
216
+
217
+
218
+ .actions { display: flex; align-items: center; gap: var(--space-3); margin-left: auto; }
219
+ .actions .btn { min-height: 44px; padding: 0 var(--space-5); font-size: 16px; }
220
+
221
+ .mobile { display: none; }
222
+ /* Google's own button: "Continue as <name>" with their photo for anyone
223
+ signed in to Google here, plain "Continue with Google" otherwise.
224
+ The space is held at its final size, the button stays invisible until
225
+ Google has drawn its final version, then fades in once. The plain link
226
+ shows only if Google never arrives (blocked, offline). */
227
+ .gsi { position: relative; display: grid; align-items: center; width: 250px; height: 44px; }
228
+ .gsi > * { grid-area: 1 / 1; }
229
+ .gsi-btn, .gsi-fallback { opacity: 0; transform: translateY(3px); transition: opacity 320ms cubic-bezier(0.2, 0, 0, 1), transform 320ms cubic-bezier(0.2, 0, 0, 1); }
230
+ .gsi:global(.ready) .gsi-btn { opacity: 1; transform: none; }
231
+ .gsi-fallback { visibility: hidden; justify-self: end; }
232
+ .gsi:global(.fallback) .gsi-fallback { visibility: visible; opacity: 1; transform: none; }
233
+ @media (prefers-reduced-motion: reduce) { .gsi-btn, .gsi-fallback { transition: none; transform: none; } }
234
+ .gsi:global(.ready) .gsi-fallback { display: none; }
235
+ .mobile > summary {
236
+ display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
237
+ min-height: 44px; min-width: 44px; padding: 0 var(--space-3);
238
+ border-radius: var(--radius-control); font-size: 16px; font-weight: 500;
239
+ transition: background-color var(--fast) var(--ease);
240
+ }
241
+ .mobile > summary:active { background: var(--subtle); }
242
+ /* Three bars that fold into a cross. */
243
+ .bars { position: relative; width: 20px; height: 14px; }
244
+ .bars::before, .bars::after, .bars i { content: ''; position: absolute; left: 0; width: 100%; height: 2px; border-radius: 1px; background: currentColor; transition: transform 380ms cubic-bezier(0.22, 1, 0.36, 1), opacity 200ms ease; }
245
+ .bars::before { top: 0; }
246
+ .bars i { top: 6px; }
247
+ .bars::after { top: 12px; }
248
+ .mobile[open]:not(.closing) .bars::before { transform: translateY(6px) rotate(45deg); }
249
+ .mobile[open]:not(.closing) .bars::after { transform: translateY(-6px) rotate(-45deg); }
250
+ .mobile[open]:not(.closing) .bars i { opacity: 0; transform: scaleX(0.3); }
251
+
252
+ .mobile-panel {
253
+ position: fixed; left: 0; right: 0; top: var(--header-h, 109px); height: calc(100dvh - var(--header-h, 109px)); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
254
+ display: flex; flex-direction: column;
255
+ background: var(--canvas); padding: var(--space-3) var(--gutter) 0;
256
+ }
257
+ /* Big top-level rows; Products and Solutions open in place as accordions. */
258
+ .mobile-panel ul { list-style: none; margin: 0; padding: 0; }
259
+ .m-list > li { border-bottom: 1px solid var(--line); }
260
+ .m-row {
261
+ display: flex; align-items: center; justify-content: space-between; min-height: 64px;
262
+ color: var(--ink); text-decoration: none; font-size: 22px; font-weight: 600; cursor: pointer; list-style: none;
263
+ }
264
+ .m-row::-webkit-details-marker { display: none; }
265
+ .m-row[aria-current='page'] { color: var(--link); }
266
+ .m-row :global(.m-chev) { color: var(--ink-muted); transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1); }
267
+ .m-acc[open] .m-row :global(.m-chev) { transform: rotate(180deg); color: var(--brand); }
268
+ .m-acc { interpolate-size: allow-keywords; }
269
+ .m-acc::details-content { block-size: 0; overflow: hidden; transition: block-size 320ms cubic-bezier(0.22, 1, 0.36, 1), content-visibility 320ms allow-discrete; }
270
+ .m-acc[open]::details-content { block-size: auto; }
271
+ .m-sub { padding: 0 0 var(--space-4) !important; }
272
+ .m-sub a { display: flex; align-items: center; min-height: 44px; color: var(--ink-muted); text-decoration: none; font-size: 17px; font-weight: 500; }
273
+ .m-sub a:active, .m-sub a[aria-current='page'] { color: var(--link); }
274
+ .m-small { display: grid; gap: var(--space-1); margin-top: var(--space-5) !important; }
275
+ .m-small a { display: flex; align-items: center; min-height: 40px; color: var(--ink-muted); text-decoration: none; font-size: 16px; }
276
+ /* Call and demo stay pinned to the bottom of the sheet while it scrolls. */
277
+ .mobile-actions { position: sticky; bottom: 0; margin-top: auto; padding: var(--space-4) 0 calc(var(--space-4) + env(safe-area-inset-bottom)); background: var(--canvas); border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
278
+ .mobile-actions .btn { width: 100%; }
279
+
280
+ /* Open: the sheet fades down into place and its rows follow in turn.
281
+ Close: it lifts away quickly. */
282
+ .mobile[open] .mobile-panel { animation: sheet-in 420ms cubic-bezier(0.22, 1, 0.36, 1); }
283
+ .mobile[open] .mobile-panel > * { animation: item-in 520ms cubic-bezier(0.22, 1, 0.36, 1) both; }
284
+ .mobile[open] .mobile-panel > :nth-child(2) { animation-delay: 60ms; }
285
+ .mobile[open] .mobile-panel > :nth-child(3) { animation-delay: 120ms; }
286
+ .mobile[open] .mobile-panel > :nth-child(4) { animation-delay: 180ms; }
287
+ .mobile.closing .mobile-panel { animation: sheet-out 240ms cubic-bezier(0.4, 0, 1, 1) forwards; }
288
+ @keyframes sheet-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
289
+ @keyframes sheet-out { to { opacity: 0; transform: translateY(-8px); } }
290
+ :global(html.menu-locked), :global(html.menu-locked body) { overflow: hidden; }
291
+
292
+ @media (max-width: 599px) { .gsi { display: none; } }
293
+ @media (max-width: 1023px) {
294
+ .bar { gap: var(--space-4); }
295
+ .nav-wide { display: none; }
296
+ .mobile { display: block; }
297
+ }
298
+ @media (max-width: 599px) {
299
+ .u-links { display: none; }
300
+ .u-row { justify-content: center; }
301
+ }
302
+ @media (max-width: 399px) {
303
+ .logo img { width: 112px; }
304
+ .actions { gap: var(--space-2); }
305
+ .actions .btn { padding: 0 var(--space-3); }
306
+ .mobile-label { display: none; }
307
+ }
308
+ @media (prefers-reduced-motion: reduce) { .menu .mega, .menu .mega-links li, .menu .mega-feature, .mobile .mobile-panel, .mobile .mobile-panel > * { animation: none !important; } .bars::before, .bars::after, .bars i, .m-row :global(.m-chev) { transition: none; } .m-acc::details-content { transition: none; } .nav-link::before, .menu > summary::before { transition: none; } }
309
+ </style>
@@ -0,0 +1,44 @@
1
+ ---
2
+ // "Related" block: a few columns of links to other pages on the same topic.
3
+ // Empty groups are left out; nothing renders when every group is empty.
4
+ import ArrowRight from '@lucide/astro/icons/arrow-right';
5
+ import type { Link } from '../../contract';
6
+ export interface Props { groups: { h: string; items: Link[] }[] }
7
+ const groups = Astro.props.groups.filter((g) => g.items.length);
8
+ ---
9
+ {groups.length > 0 && (
10
+ <section class="section-tight related" data-reveal aria-label="Related pages">
11
+ <div class="wrap cols" style={`--n:${groups.length}`}>
12
+ {groups.map((g) => (
13
+ <div>
14
+ <h2 class="h">{g.h}</h2>
15
+ <ul data-stagger>
16
+ {g.items.map((l, i) => (
17
+ <li style={`--i:${i}`}>
18
+ <a href={l.href}>
19
+ <span class="t">{l.label}</span>
20
+ {l.meta && <span class="m">{l.meta}</span>}
21
+ <ArrowRight class="go" size={16} stroke-width={2} aria-hidden="true" />
22
+ </a>
23
+ </li>
24
+ ))}
25
+ </ul>
26
+ </div>
27
+ ))}
28
+ </div>
29
+ </section>
30
+ )}
31
+
32
+ <style>
33
+ .related { border-top: 1px solid var(--line); }
34
+ .cols { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: var(--space-7); }
35
+ .h { font-size: 1rem; font-family: var(--font-sans); font-weight: 600; color: var(--ink-muted); margin-bottom: var(--space-3); }
36
+ ul { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--line); }
37
+ a { display: grid; grid-template-columns: 1fr auto; grid-template-areas: 't go' 'm go'; align-items: center; gap: 0 var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; }
38
+ .t { grid-area: t; font-size: 16px; font-weight: 500; line-height: 1.35; transition: color var(--fast) var(--ease); }
39
+ .m { grid-area: m; font-size: 14px; color: var(--ink-muted); }
40
+ a :global(.go) { grid-area: go; color: var(--ink-muted); transition: transform var(--fast) var(--ease), color var(--fast) var(--ease); }
41
+ a:hover .t { color: var(--link); }
42
+ a:hover :global(.go) { transform: translateX(3px); color: var(--link); }
43
+ @media (max-width: 767px) { .cols { grid-template-columns: 1fr; gap: var(--space-6); } }
44
+ </style>
package/src/config.ts ADDED
@@ -0,0 +1,55 @@
1
+ // The site's settings as the kit reads them: '@site/config/site' for
2
+ // constants and '@site/config/kit' for everything else, merged over defaults.
3
+ import * as constants from '@site/config/site';
4
+ import { kit as siteKitRaw } from '@site/config/kit';
5
+ import type { KitConfig, OptionalSiteConstants, SiteKit } from './contract';
6
+
7
+ const siteKit: SiteKit = siteKitRaw;
8
+ const c = constants as unknown as Record<string, unknown>;
9
+ const get = <K extends keyof OptionalSiteConstants>(key: K) => c[key] as OptionalSiteConstants[K] | undefined;
10
+
11
+ export const SITE_URL = c['SITE_URL'] as string;
12
+ export const SITE_NAME = c['SITE_NAME'] as string;
13
+ export const COMPANY = get('COMPANY');
14
+ export const CONTACT_EMAIL = get('CONTACT_EMAIL');
15
+ export const CONTACT_PHONE_DISPLAY = get('CONTACT_PHONE_DISPLAY');
16
+ export const CONTACT_PHONE_TEL = get('CONTACT_PHONE_TEL');
17
+ export const CONTACT_PHONE_JSONLD = get('CONTACT_PHONE_JSONLD');
18
+ export const OFFICE_LINE = get('OFFICE_LINE');
19
+ export const LEGAL_ADDRESS = get('LEGAL_ADDRESS');
20
+ export const LEGAL_ADDRESS_LINE = get('LEGAL_ADDRESS_LINE');
21
+ export const SOCIAL_PROFILES = get('SOCIAL_PROFILES') ?? [];
22
+ export const PARENT_COMPANY_NAME = get('PARENT_COMPANY_NAME');
23
+ export const PARENT_COMPANY_URL = get('PARENT_COMPANY_URL');
24
+ export const PARENT_COMPANY_ID = get('PARENT_COMPANY_ID');
25
+ export const TAG_ACRONYMS = get('TAG_ACRONYMS') ?? [];
26
+
27
+ /** The site's KitConfig. Sections the site leaves out fall back to these defaults. */
28
+ export const kit: KitConfig = {
29
+ blog: {
30
+ label: 'Blog',
31
+ name: `${SITE_NAME} blog`,
32
+ description: `Guides and notes from ${SITE_NAME}.`,
33
+ rssDescription: `Guides and notes from ${SITE_NAME}.`,
34
+ pageDescription: (n, last) => `Older ${SITE_NAME} guides. Page ${n} of ${last}.`,
35
+ tagDescription: (label) => `${SITE_NAME} articles about ${label.toLowerCase()}.`,
36
+ about: SITE_NAME,
37
+ imageCredit: SITE_NAME,
38
+ ...siteKit.blog,
39
+ },
40
+ seo: { hreflang: 'en', ogLocale: 'en_US', logo: '/favicon.svg', ...siteKit.seo },
41
+ head: { preloadFonts: [], icons: [], ...siteKit.head },
42
+ header: siteKit.header,
43
+ footer: siteKit.footer,
44
+ cta: siteKit.cta,
45
+ og: siteKit.og,
46
+ glossary: {
47
+ name: `${SITE_NAME} glossary`,
48
+ ogTitle: 'Glossary',
49
+ indexTitle: 'Glossary',
50
+ indexDescription: `Plain definitions of the terms used on ${SITE_NAME}.`,
51
+ ...siteKit.glossary,
52
+ },
53
+ llms: siteKit.llms,
54
+ dashain: siteKit.dashain,
55
+ };
@@ -0,0 +1,173 @@
1
+ // The contract between the kit and a site. The integration aliases '@site' to
2
+ // the site's src/, and kit code imports the modules below from it.
3
+ //
4
+ // @site/config/site constants (SITE_URL, SITE_NAME, contact, address ...)
5
+ // @site/config/kit everything else the kit reads: KitConfig (see below)
6
+ // @site/data/links product/solution link helpers (type SiteLinks)
7
+ // @site/layouts/Base.astro the site's layout, a thin wrapper around the kit's
8
+ // @site/styles/site.css imports the kit's base.css and motion.css
9
+ // @site/data/glossary/terms/*.ts one Term per file (only when the glossary is on)
10
+ //
11
+ // plus the Astro content collection `blog`, defined in the site's
12
+ // src/content.config.ts with `postSchema` from the kit.
13
+
14
+ export type { Term } from './lib/glossary-types';
15
+
16
+ export interface Link {
17
+ href: string;
18
+ label: string;
19
+ meta?: string;
20
+ }
21
+
22
+ /** Required constants in '@site/config/site'. */
23
+ export interface SiteConstants {
24
+ SITE_URL: string;
25
+ SITE_NAME: string;
26
+ }
27
+
28
+ /**
29
+ * Optional constants in '@site/config/site'. When present they feed the
30
+ * Organization structured data, the footer and the llms.txt page.
31
+ */
32
+ export interface OptionalSiteConstants {
33
+ COMPANY: string;
34
+ CONTACT_EMAIL: string;
35
+ CONTACT_PHONE_DISPLAY: string;
36
+ CONTACT_PHONE_TEL: string;
37
+ CONTACT_PHONE_JSONLD: string;
38
+ OFFICE_LINE: string;
39
+ LEGAL_ADDRESS: { street: string; locality: string; region: string; postal: string; country: string };
40
+ LEGAL_ADDRESS_LINE: string;
41
+ SOCIAL_PROFILES: readonly string[];
42
+ PARENT_COMPANY_NAME: string;
43
+ PARENT_COMPANY_URL: string;
44
+ PARENT_COMPANY_ID: string;
45
+ /** Words kept upper-case in topic labels: ['ai', 'sip']. */
46
+ TAG_ACRONYMS: readonly string[];
47
+ }
48
+
49
+ /** '@site/data/links': how blog posts and glossary terms point at products. */
50
+ export interface SiteLinks {
51
+ productTags: Record<string, string[]>;
52
+ productLink(slug: string): Link | null;
53
+ productsForTags(tags: string[]): Link[];
54
+ solutionsForTags(tags: string[]): Link[];
55
+ }
56
+
57
+ export interface HeaderLink {
58
+ href: string;
59
+ label: string;
60
+ }
61
+
62
+ export interface HeaderGroup {
63
+ id: string;
64
+ label: string;
65
+ /** Path prefix that marks the group current. */
66
+ base: string;
67
+ links: HeaderLink[];
68
+ feature: { title: string; href: string; cta: string };
69
+ }
70
+
71
+ export interface HeaderConfig {
72
+ homeLabel: string;
73
+ logo: { light: string; dark: string; alt: string; width: number; height: number };
74
+ /** The thin strip above the bar. `text` is plain, `mono` is set in the mono face. */
75
+ utility: { lead: { href: string; text: string; mono?: string }; links: HeaderLink[] };
76
+ groups: HeaderGroup[];
77
+ /** Links in the bar after the groups. */
78
+ plain: HeaderLink[];
79
+ /** The bar's call to action. `google` draws Google's own sign-in button with this link as the fallback. */
80
+ action: { href: string; label: string; google?: boolean };
81
+ /** Small links at the foot of the mobile sheet. */
82
+ mobileLinks: HeaderLink[];
83
+ mobileCall: HeaderLink;
84
+ }
85
+
86
+ export interface FooterConfig {
87
+ /** The mark above the contact lines. */
88
+ mark: { src: string; width: number; height: number };
89
+ columns: { title: string; links: HeaderLink[] }[];
90
+ }
91
+
92
+ export interface OgConfig {
93
+ background: string;
94
+ ink: string;
95
+ muted: string;
96
+ /** SVG in public/ drawn beside the site name; `from` is the fill replaced by `fill`. */
97
+ mark: { file: string; from: string; fill: string; width: number; height: number };
98
+ /** Pages the site owns: static pages, products, solutions. The kit adds blog, tag and glossary cards. */
99
+ pages: () => { slug: string; title: string }[];
100
+ }
101
+
102
+ export interface LlmsSection {
103
+ title: string;
104
+ items: string[];
105
+ }
106
+
107
+ export interface KitConfig {
108
+ blog: {
109
+ /** Heading, navigation label and breadcrumb for the blog ('Insights'). */
110
+ label: string;
111
+ /** Feed and share-card name ('AirFone blog'). */
112
+ name: string;
113
+ description: string;
114
+ rssDescription: string;
115
+ pageDescription: (n: number, last: number) => string;
116
+ tagDescription: (label: string) => string;
117
+ /** Schema.org `about` of every post. */
118
+ about: string;
119
+ /** Credit line on the site's own images. */
120
+ imageCredit: string;
121
+ };
122
+ seo: {
123
+ hreflang: string;
124
+ ogLocale: string;
125
+ logo: string;
126
+ contactPoint?: { contactType: string; areaServed: string; availableLanguage: string[] };
127
+ };
128
+ head: {
129
+ /** Font files preloaded on every page (resolved `?url` imports). */
130
+ preloadFonts: string[];
131
+ icons: { rel: string; href: string; type?: string; sizes?: string }[];
132
+ manifest?: string;
133
+ };
134
+ header: HeaderConfig;
135
+ footer: FooterConfig;
136
+ cta: { heading: string; actions: { href: string; label: string; class: string }[] };
137
+ og: OgConfig;
138
+ glossary: {
139
+ name: string;
140
+ ogTitle: string;
141
+ indexTitle: string;
142
+ indexDescription: string;
143
+ };
144
+ llms: {
145
+ description: string;
146
+ facts: string[];
147
+ before: () => LlmsSection[];
148
+ after: () => LlmsSection[];
149
+ };
150
+ /** The seasonal popup; leave out to keep it off. */
151
+ dashain?: { enabled: boolean; greetingUrl: string; ctaHref: string };
152
+ }
153
+
154
+ /** What '@site/config/kit' exports as `kit`: header, footer, cta, og and llms are required, the rest fall back to defaults. */
155
+ export interface SiteKit {
156
+ blog?: Partial<KitConfig['blog']>;
157
+ seo?: Partial<KitConfig['seo']>;
158
+ head?: Partial<KitConfig['head']>;
159
+ glossary?: Partial<KitConfig['glossary']>;
160
+ header: HeaderConfig;
161
+ footer: FooterConfig;
162
+ cta: KitConfig['cta'];
163
+ og: OgConfig;
164
+ llms: KitConfig['llms'];
165
+ dashain?: KitConfig['dashain'];
166
+ }
167
+
168
+ export type PageName = 'blog' | 'glossary' | 'og' | 'rss' | 'llms';
169
+
170
+ export interface SiteKitOptions {
171
+ /** Set a page to false to keep the kit from injecting it (the site supplies its own). */
172
+ pages?: Partial<Record<PageName, boolean>>;
173
+ }
@@ -0,0 +1,4 @@
1
+ import type { AstroIntegration } from 'astro';
2
+ import type { SiteKitOptions } from './contract';
3
+
4
+ export default function siteKit(options?: SiteKitOptions): AstroIntegration;
@@ -0,0 +1,61 @@
1
+ // The Astro integration every site adds: `integrations: [siteKit()]`. Plain
2
+ // JavaScript so Node can load it from node_modules when astro.config runs.
3
+ import { fileURLToPath } from 'node:url';
4
+ import { join } from 'node:path';
5
+ import { rehypeFigures } from './lib/rehype-figures.mjs';
6
+
7
+ const PACKAGE = '@ninjainfosys/site-kit';
8
+
9
+ // Pages that are the same on every site. The site turns one off with
10
+ // `siteKit({ pages: { glossary: false } })` and supplies its own.
11
+ /** @type {Record<import('./contract').PageName, { pattern: string; entrypoint: string }[]>} */
12
+ const PAGES = {
13
+ blog: [
14
+ { pattern: '/blog', entrypoint: 'blog/index.astro' },
15
+ { pattern: '/blog/[slug]', entrypoint: 'blog/[slug].astro' },
16
+ { pattern: '/blog/page/[page]', entrypoint: 'blog/page/[page].astro' },
17
+ { pattern: '/blog/tag/[tag]', entrypoint: 'blog/tag/[tag].astro' },
18
+ ],
19
+ glossary: [
20
+ { pattern: '/glossary', entrypoint: 'glossary/index.astro' },
21
+ { pattern: '/glossary/[slug]', entrypoint: 'glossary/[slug].astro' },
22
+ ],
23
+ og: [{ pattern: '/og/[...slug].png', entrypoint: 'og/[...slug].png.ts' }],
24
+ rss: [{ pattern: '/rss.xml', entrypoint: 'rss.xml.ts' }],
25
+ llms: [{ pattern: '/llms.txt', entrypoint: 'llms.txt.ts' }],
26
+ };
27
+
28
+ /**
29
+ * @param {import('./contract').SiteKitOptions} [options]
30
+ * @returns {import('astro').AstroIntegration}
31
+ */
32
+ export default function siteKit(options = {}) {
33
+ return {
34
+ name: PACKAGE,
35
+ hooks: {
36
+ 'astro:config:setup': ({ config, updateConfig, injectRoute }) => {
37
+ updateConfig({
38
+ markdown: { rehypePlugins: [rehypeFigures] },
39
+ vite: {
40
+ resolve: {
41
+ // Kit code imports the site's own modules as '@site/...'.
42
+ alias: { '@site': join(fileURLToPath(config.root), 'src') },
43
+ // One copy of Astro and its runtime, whichever package a file lives in.
44
+ dedupe: ['astro'],
45
+ },
46
+ // The kit ships .astro and .ts source for Vite to compile. resvg is a
47
+ // native module used only at build time for share images; Vite must
48
+ // load it from node_modules instead of trying to bundle the .node file.
49
+ ssr: { noExternal: [PACKAGE], external: ['@resvg/resvg-js'] },
50
+ optimizeDeps: { exclude: ['@resvg/resvg-js'] },
51
+ build: { rollupOptions: { external: [/\.node$/] } },
52
+ },
53
+ });
54
+ for (const [name, routes] of Object.entries(PAGES)) {
55
+ if (options.pages?.[name] === false) continue;
56
+ for (const r of routes) injectRoute({ pattern: r.pattern, entrypoint: `${PACKAGE}/pages/${r.entrypoint}` });
57
+ }
58
+ },
59
+ },
60
+ };
61
+ }