@ninjainfosys/site-kit 0.1.0 → 0.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninjainfosys/site-kit",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Shared blog, glossary, SEO, layout and build tooling for the Ninja Infosys Astro marketing sites.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -13,20 +13,24 @@ export interface Props {
13
13
  jsonLd?: object[];
14
14
  published?: Date;
15
15
  modified?: Date;
16
+ pageType?: string;
16
17
  }
17
18
 
18
- const { title, description, path, image, imageAlt, type = 'website', noindex = false, jsonLd = [], published, modified } = Astro.props;
19
+ const { title, description, path, image, imageAlt, type = 'website', noindex = false, jsonLd = [], published, modified, pageType } = Astro.props;
19
20
  const fullTitle = titleFor(title);
20
21
  const canonical = canonicalFor(path);
21
22
  const ogPath = image ?? `/og${path === '/' ? '/index' : path}.png`;
22
23
  const ogImage = abs(ogPath);
23
- const graph = [orgJsonLd(), websiteJsonLd(), ...jsonLd];
24
+ const page = kit.seo.webPage?.({ name: fullTitle, description, path, type: pageType, published, modified });
25
+ const graph = [orgJsonLd(), websiteJsonLd(), ...(page ? [page] : []), ...jsonLd];
24
26
  ---
25
27
  <title>{fullTitle}</title>
26
28
  <meta name="description" content={description} />
27
29
  <link rel="canonical" href={canonical} />
28
30
  {!noindex && <><link rel="alternate" hreflang={kit.seo.hreflang} href={canonical} /><link rel="alternate" hreflang="x-default" href={canonical} /></>}
29
31
  {noindex && <meta name="robots" content="noindex, follow" />}
32
+ {kit.seo.author && <meta name="author" content={kit.seo.author} />}
33
+ {!noindex && kit.seo.robots && <meta name="robots" content={kit.seo.robots} />}
30
34
  <meta property="og:site_name" content={SITE_NAME} />
31
35
  <meta property="og:type" content={type} />
32
36
  <meta property="og:title" content={fullTitle} />
@@ -1,5 +1,5 @@
1
1
  ---
2
- import { CONTACT_EMAIL, CONTACT_PHONE_DISPLAY, CONTACT_PHONE_TEL, OFFICE_LINE, LEGAL_ADDRESS_LINE, SOCIAL_PROFILES, PARENT_COMPANY_NAME, PARENT_COMPANY_URL, SITE_NAME, kit } from '../../config';
2
+ import { COMPANY, CONTACT_EMAIL, CONTACT_PHONE_DISPLAY, CONTACT_PHONE_TEL, OFFICE_LINE, LEGAL_ADDRESS_LINE, SOCIAL_PROFILES, PARENT_COMPANY_NAME, PARENT_COMPANY_URL, SITE_NAME, kit } from '../../config';
3
3
  import { siFacebook, siInstagram, siTiktok } from 'simple-icons';
4
4
 
5
5
  // LinkedIn is not in simple-icons; this is its standard "in" mark.
@@ -10,13 +10,15 @@ const icon: Record<string, { name: string; path: string }> = {
10
10
  tiktok: { name: 'TikTok', path: siTiktok.path },
11
11
  linkedin: { name: 'LinkedIn', path: linkedin },
12
12
  };
13
- const social = SOCIAL_PROFILES.map((href) => ({ href, ...icon[Object.keys(icon).find((k) => href.includes(k))!] }));
13
+ const social = (SOCIAL_PROFILES ?? []).map((href) => ({ href, ...icon[Object.keys(icon).find((k) => href.includes(k))!] }));
14
14
  ---
15
15
  <footer class="site-footer">
16
16
  <div class="wrap">
17
17
  <div class="top">
18
18
  <div class="brand">
19
- <img src={kit.footer.mark.src} alt="" width={kit.footer.mark.width} height={kit.footer.mark.height} class="cloud" aria-hidden="true" />
19
+ {kit.footer.mark.text
20
+ ? <p class="mark"><img src={kit.footer.mark.src} alt="" width={kit.footer.mark.width} height={kit.footer.mark.height} class="cloud" aria-hidden="true" /><span class="mark-text">{kit.footer.mark.text}</span></p>
21
+ : <img src={kit.footer.mark.src} alt="" width={kit.footer.mark.width} height={kit.footer.mark.height} class="cloud" aria-hidden="true" />}
20
22
  <p class="contact">
21
23
  <a href={CONTACT_PHONE_TEL}>{CONTACT_PHONE_DISPLAY}</a><br />
22
24
  <a href={`mailto:${CONTACT_EMAIL}`}>{CONTACT_EMAIL}</a><br />
@@ -35,7 +37,9 @@ const social = SOCIAL_PROFILES.map((href) => ({ href, ...icon[Object.keys(icon).
35
37
  </nav>
36
38
  ))}
37
39
  </div>
38
- <p class="legal muted">© {new Date().getFullYear()} <a href={PARENT_COMPANY_URL} rel="noopener">{PARENT_COMPANY_NAME}</a>, {LEGAL_ADDRESS_LINE}</p>
40
+ {kit.footer.legal === 'company'
41
+ ? <p class="legal muted">© {new Date().getFullYear()} {COMPANY}, {LEGAL_ADDRESS_LINE} Part of <a href={PARENT_COMPANY_URL} rel="noopener">{PARENT_COMPANY_NAME}</a>.</p>
42
+ : <p class="legal muted">© {new Date().getFullYear()} <a href={PARENT_COMPANY_URL} rel="noopener">{PARENT_COMPANY_NAME}</a>, {LEGAL_ADDRESS_LINE}</p>}
39
43
  </div>
40
44
  </footer>
41
45
 
@@ -14,8 +14,8 @@ const current = (href: string) => (path === href || path.startsWith(`${href}/`)
14
14
  <div class="utility">
15
15
  <div class="wrap u-row">
16
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></>)}
17
+ <nav aria-label={utility.label ?? 'Utility'} class="u-links">
18
+ {utility.links.map((l, i) => <>{i > 0 && !utility.joined && ' '}<a href={l.href}>{l.label}</a></>)}
19
19
  </nav>
20
20
  </div>
21
21
  </div>
@@ -23,8 +23,11 @@ const current = (href: string) => (path === href || path.startsWith(`${href}/`)
23
23
  <header class="site-header">
24
24
  <div class="wrap bar">
25
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" />
26
+ {logo.kind === 'mark'
27
+ ? <><img src={logo.light} alt="" width={logo.width} height={logo.height} class="logo-mark" aria-hidden="true" />{' '}<span class="logo-name">{logo.text}</span></>
28
+ : <>{logo.alt
29
+ ? <img src={logo.light} alt={logo.alt} width={logo.width} height={logo.height} class="logo-light" />
30
+ : <img src={logo.light} alt="" width={logo.width} height={logo.height} class="logo-light" />}{' '}<img src={logo.dark} alt="" width={logo.width} height={logo.height} class="logo-dark" aria-hidden="true" />{logo.text && <>{' '}<span class="logo-text">{logo.text}</span></>}</>}
28
31
  </a>
29
32
 
30
33
  <nav class="nav-wide" aria-label="Main">
@@ -37,7 +40,7 @@ const current = (href: string) => (path === href || path.startsWith(`${href}/`)
37
40
  <div class="wrap mega-grid">
38
41
  <ul class="mega-links">
39
42
  {g.links.map((l) => (
40
- <li><a href={l.href} aria-current={current(l.href)}><span class="m-name">{l.label}</span></a></li>
43
+ <li><a href={l.href} aria-current={current(l.href)}>{l.logo && <img class="m-logo" src={l.logo} alt="" width="28" height="28" />}<span class="m-name">{l.label}</span></a></li>
41
44
  ))}
42
45
  </ul>
43
46
  <a class="mega-feature" href={g.feature.href}>
package/src/config.ts CHANGED
@@ -18,7 +18,8 @@ export const CONTACT_PHONE_JSONLD = get('CONTACT_PHONE_JSONLD');
18
18
  export const OFFICE_LINE = get('OFFICE_LINE');
19
19
  export const LEGAL_ADDRESS = get('LEGAL_ADDRESS');
20
20
  export const LEGAL_ADDRESS_LINE = get('LEGAL_ADDRESS_LINE');
21
- export const SOCIAL_PROFILES = get('SOCIAL_PROFILES') ?? [];
21
+ /** Undefined when the site has none to declare; an empty list is still sent as `sameAs: []`. */
22
+ export const SOCIAL_PROFILES = get('SOCIAL_PROFILES');
22
23
  export const PARENT_COMPANY_NAME = get('PARENT_COMPANY_NAME');
23
24
  export const PARENT_COMPANY_URL = get('PARENT_COMPANY_URL');
24
25
  export const PARENT_COMPANY_ID = get('PARENT_COMPANY_ID');
@@ -33,14 +34,13 @@ export const kit: KitConfig = {
33
34
  rssDescription: `Guides and notes from ${SITE_NAME}.`,
34
35
  pageDescription: (n, last) => `Older ${SITE_NAME} guides. Page ${n} of ${last}.`,
35
36
  tagDescription: (label) => `${SITE_NAME} articles about ${label.toLowerCase()}.`,
36
- about: SITE_NAME,
37
37
  imageCredit: SITE_NAME,
38
38
  ...siteKit.blog,
39
39
  },
40
40
  seo: { hreflang: 'en', ogLocale: 'en_US', logo: '/favicon.svg', ...siteKit.seo },
41
41
  head: { preloadFonts: [], icons: [], ...siteKit.head },
42
42
  header: siteKit.header,
43
- footer: siteKit.footer,
43
+ footer: siteKit.footer as KitConfig['footer'],
44
44
  cta: siteKit.cta,
45
45
  og: siteKit.og,
46
46
  glossary: {
package/src/contract.ts CHANGED
@@ -44,6 +44,8 @@ export interface OptionalSiteConstants {
44
44
  PARENT_COMPANY_ID: string;
45
45
  /** Words kept upper-case in topic labels: ['ai', 'sip']. */
46
46
  TAG_ACRONYMS: readonly string[];
47
+ /** Words shown as written in topic labels: { airfone: 'AirFone' }. */
48
+ TAG_WORDS: Record<string, string>;
47
49
  }
48
50
 
49
51
  /** '@site/data/links': how blog posts and glossary terms point at products. */
@@ -57,6 +59,8 @@ export interface SiteLinks {
57
59
  export interface HeaderLink {
58
60
  href: string;
59
61
  label: string;
62
+ /** Small image before the label in the mega menu. */
63
+ logo?: string;
60
64
  }
61
65
 
62
66
  export interface HeaderGroup {
@@ -70,9 +74,10 @@ export interface HeaderGroup {
70
74
 
71
75
  export interface HeaderConfig {
72
76
  homeLabel: string;
73
- logo: { light: string; dark: string; alt: string; width: number; height: number };
77
+ /** `text` sets a wordmark beside the logo images. */
78
+ logo: { light: string; dark: string; alt: string; width: number; height: number; text?: string; kind?: 'lockup' | 'mark' };
74
79
  /** 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[] };
80
+ utility: { lead: { href: string; text: string; mono?: string }; links: HeaderLink[]; /** aria-label of the strip's links; default Utility. */ label?: string; /** Write the links with no space between them. */ joined?: boolean };
76
81
  groups: HeaderGroup[];
77
82
  /** Links in the bar after the groups. */
78
83
  plain: HeaderLink[];
@@ -85,7 +90,10 @@ export interface HeaderConfig {
85
90
 
86
91
  export interface FooterConfig {
87
92
  /** The mark above the contact lines. */
88
- mark: { src: string; width: number; height: number };
93
+ /** `text` sets a wordmark beside the mark. */
94
+ mark: { src: string; width: number; height: number; text?: string };
95
+ /** 'parent' links the parent company; 'company' names the company, then "Part of <parent>". */
96
+ legal?: 'parent' | 'company';
89
97
  columns: { title: string; links: HeaderLink[] }[];
90
98
  }
91
99
 
@@ -93,8 +101,12 @@ export interface OgConfig {
93
101
  background: string;
94
102
  ink: string;
95
103
  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 };
104
+ /** Font from @fontsource/<package>, loaded at 400 and 600; default Poppins. */
105
+ font?: { family: string; package: string };
106
+ /** Name beside the mark; default is SITE_NAME at 40px, weight 600. */
107
+ name?: { text: string; size: number; weight: number };
108
+ /** SVG in public/ drawn beside the site name; `from` is the fill replaced by `fill` (leave both out to use it as is). */
109
+ mark: { file: string; from?: string; fill?: string; width: number; height: number; /** Embed a PNG file as is. */ png?: boolean; /** Draw the mark on a plate. */ plate?: { background: string; radius: number; padding: number } };
98
110
  /** Pages the site owns: static pages, products, solutions. The kit adds blog, tag and glossary cards. */
99
111
  pages: () => { slug: string; title: string }[];
100
112
  }
@@ -114,15 +126,35 @@ export interface KitConfig {
114
126
  rssDescription: string;
115
127
  pageDescription: (n: number, last: number) => string;
116
128
  tagDescription: (label: string) => string;
129
+ /** What a topic page calls its posts in its title and share card; default 'articles'. */
130
+ tagNoun?: string;
131
+ /** Headings of the related block under a post. */
132
+ related?: { products: string; industries: string; more: string };
133
+ /** Title of the blog front when it differs from the label. */
134
+ indexTitle?: string;
135
+ /** Schema.org type of the blog front and extra structured data for it. */
136
+ indexPageType?: string;
137
+ indexJsonLd?: (posts: { slug: string; title: string; description: string; date: Date }[]) => object[];
117
138
  /** Schema.org `about` of every post. */
118
- about: string;
139
+ /** Schema.org `about` of every post; left out when not set. */
140
+ about?: string;
119
141
  /** Credit line on the site's own images. */
120
142
  imageCredit: string;
121
143
  };
122
144
  seo: {
123
145
  hreflang: string;
124
146
  ogLocale: string;
125
- logo: string;
147
+ logo: string | object;
148
+ /** Replaces the generated Organization data. */
149
+ orgJsonLd?: () => object;
150
+ /** Replaces the page title rule (brand suffix, length). */
151
+ titleFor?: (page?: string) => string;
152
+ /** WebPage data added to every page. */
153
+ webPage?: (p: { name: string; description: string; path: string; type?: string; published?: Date; modified?: Date }) => object;
154
+ /** `<meta name="author">`. */
155
+ author?: string;
156
+ /** `<meta name="robots">` content for indexable pages. */
157
+ robots?: string;
126
158
  contactPoint?: { contactType: string; areaServed: string; availableLanguage: string[] };
127
159
  };
128
160
  head: {
@@ -132,7 +164,7 @@ export interface KitConfig {
132
164
  manifest?: string;
133
165
  };
134
166
  header: HeaderConfig;
135
- footer: FooterConfig;
167
+ footer?: FooterConfig;
136
168
  cta: { heading: string; actions: { href: string; label: string; class: string }[] };
137
169
  og: OgConfig;
138
170
  glossary: {
@@ -158,7 +190,8 @@ export interface SiteKit {
158
190
  head?: Partial<KitConfig['head']>;
159
191
  glossary?: Partial<KitConfig['glossary']>;
160
192
  header: HeaderConfig;
161
- footer: FooterConfig;
193
+ /** Leave out when the site renders its own footer in the layout's footer slot. */
194
+ footer?: FooterConfig;
162
195
  cta: KitConfig['cta'];
163
196
  og: OgConfig;
164
197
  llms: KitConfig['llms'];
@@ -1,10 +1,37 @@
1
1
  // The Astro integration every site adds: `integrations: [siteKit()]`. Plain
2
2
  // JavaScript so Node can load it from node_modules when astro.config runs.
3
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
3
4
  import { fileURLToPath } from 'node:url';
4
5
  import { join } from 'node:path';
5
6
  import { rehypeFigures } from './lib/rehype-figures.mjs';
6
7
 
7
8
  const PACKAGE = '@ninjainfosys/site-kit';
9
+ const BLOG_IMAGES = 'virtual:site-kit/blog-images';
10
+ const IMAGE = /\.(jpe?g|png|webp|avif)$/i;
11
+
12
+ /**
13
+ * The images of the posts that will be published, as one module. A glob over
14
+ * src/assets/blog would also emit the images of draft posts (and of folders
15
+ * with no post yet) into dist; this lists only posts that ship. The dev server
16
+ * lists every post so drafts can be reviewed.
17
+ */
18
+ function blogImages(root, dev) {
19
+ const posts = join(root, 'src/content/blog');
20
+ const assets = join(root, 'src/assets/blog');
21
+ const ids = [];
22
+ if (existsSync(posts) && existsSync(assets)) {
23
+ for (const f of readdirSync(posts).filter((x) => x.endsWith('.md'))) {
24
+ const fm = readFileSync(join(posts, f), 'utf8').match(/^---\r?\n([\s\S]*?)\r?\n---/)?.[1] ?? '';
25
+ if (!dev && /^draft:\s*true\s*$/m.test(fm)) continue;
26
+ const slug = f.replace(/\.md$/, '');
27
+ const dir = join(assets, slug);
28
+ if (existsSync(dir)) for (const img of readdirSync(dir).filter((x) => IMAGE.test(x)).sort()) ids.push(`/src/assets/blog/${slug}/${img}`);
29
+ }
30
+ }
31
+ const imports = ids.map((id, i) => `import m${i} from ${JSON.stringify(id)};`).join('\n');
32
+ const entries = ids.map((id, i) => `${JSON.stringify(id)}: { default: m${i} }`).join(', ');
33
+ return `${imports}\nexport default { ${entries} };\n`;
34
+ }
8
35
 
9
36
  // Pages that are the same on every site. The site turns one off with
10
37
  // `siteKit({ pages: { glossary: false } })` and supplies its own.
@@ -33,13 +60,21 @@ export default function siteKit(options = {}) {
33
60
  return {
34
61
  name: PACKAGE,
35
62
  hooks: {
36
- 'astro:config:setup': ({ config, updateConfig, injectRoute }) => {
63
+ 'astro:config:setup': ({ config, command, updateConfig, injectRoute }) => {
64
+ const root = fileURLToPath(config.root);
37
65
  updateConfig({
38
66
  markdown: { rehypePlugins: [rehypeFigures] },
39
67
  vite: {
68
+ plugins: [
69
+ {
70
+ name: 'site-kit-blog-images',
71
+ resolveId: (id) => (id === BLOG_IMAGES ? `\0${BLOG_IMAGES}` : null),
72
+ load: (id) => (id === `\0${BLOG_IMAGES}` ? blogImages(root, command === 'dev') : null),
73
+ },
74
+ ],
40
75
  resolve: {
41
76
  // Kit code imports the site's own modules as '@site/...'.
42
- alias: { '@site': join(fileURLToPath(config.root), 'src') },
77
+ alias: { '@site': join(root, 'src') },
43
78
  // One copy of Astro and its runtime, whichever package a file lives in.
44
79
  dedupe: ['astro'],
45
80
  },
@@ -18,6 +18,7 @@ export interface Props {
18
18
  jsonLd?: object[];
19
19
  published?: Date;
20
20
  modified?: Date;
21
+ pageType?: string;
21
22
  }
22
23
 
23
24
  const props = Astro.props;
@@ -32,7 +33,7 @@ const SHOW_DASHAIN_POPUP = kit.dashain?.enabled ?? false;
32
33
  <meta name="theme-color" content="#FFFFFF" />
33
34
  <meta name="color-scheme" content="light" />
34
35
  {kit.head.preloadFonts.map((href) => <link rel="preload" href={href} as="font" type="font/woff2" crossorigin />)}
35
- {kit.head.icons.map((i) => <link rel={i.rel} href={i.href} type={i.type} sizes={i.sizes} />)}
36
+ {kit.head.icons.map((i) => <link rel={i.rel} href={i.href} sizes={i.sizes} type={i.type} />)}
36
37
  {kit.head.manifest && <link rel="manifest" href={kit.head.manifest} />}
37
38
  <link rel="alternate" type="application/rss+xml" title={kit.blog.name} href="/rss.xml" />
38
39
  <Seo {...props} />
@@ -40,11 +41,11 @@ const SHOW_DASHAIN_POPUP = kit.dashain?.enabled ?? false;
40
41
  </head>
41
42
  <body>
42
43
  <a class="skip-link" href="#main">Skip to content</a>
43
- <Header />
44
+ <slot name="header"><Header /></slot>
44
45
  <main id="main">
45
46
  <slot />
46
47
  </main>
47
- <Footer />
48
+ <slot name="footer"><Footer /></slot>
48
49
  <slot name="scripts" />
49
50
  <script>
50
51
  // Fade sections in as they enter the viewport. Content is visible
package/src/lib/blog.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  import * as constants from '@site/config/site';
3
3
 
4
4
  const TAG_ACRONYMS = ((constants as Record<string, unknown>)['TAG_ACRONYMS'] as readonly string[] | undefined) ?? [];
5
+ const TAG_WORDS = ((constants as Record<string, unknown>)['TAG_WORDS'] as Record<string, string> | undefined) ?? {};
5
6
 
6
7
  export const PAGE_SIZE = 10;
7
8
 
@@ -46,10 +47,12 @@ export function pageWindow(current: number, last: number, around = 1): (number |
46
47
  return out;
47
48
  }
48
49
 
49
- const acronyms = new RegExp(`\\b(${TAG_ACRONYMS.join('|')})\\b`, 'gi');
50
+ // Words shown in a fixed form: acronyms in capitals, product names as written.
51
+ const WORDS: Record<string, string> = { ...Object.fromEntries(TAG_ACRONYMS.map((a) => [a.toLowerCase(), a.toUpperCase()])), ...TAG_WORDS };
52
+ const words = new RegExp(`\\b(${Object.keys(WORDS).join('|')})\\b`, 'gi');
50
53
  export const tagLabel = (tag: string) => {
51
54
  const label = tag.replace(/-/g, ' ').replace(/^./, (c) => c.toUpperCase());
52
- return TAG_ACRONYMS.length ? label.replace(acronyms, (w) => w.toUpperCase()) : label;
55
+ return Object.keys(WORDS).length ? label.replace(words, (w) => WORDS[w.toLowerCase()]) : label;
53
56
  };
54
57
 
55
58
  /** Posts sharing the most tags with `post`, excluding itself. */
package/src/lib/seo.ts CHANGED
@@ -12,6 +12,7 @@ export function canonicalFor(path: string): string {
12
12
  export const abs = (path: string) => (path.startsWith('http') ? path : `${SITE_URL}${path.startsWith('/') ? '' : '/'}${path}`);
13
13
 
14
14
  export function titleFor(page?: string): string {
15
+ if (kit.seo.titleFor) return kit.seo.titleFor(page);
15
16
  if (!page || page === SITE_NAME) return SITE_NAME;
16
17
  return `${page} · ${SITE_NAME}`;
17
18
  }
@@ -19,6 +20,11 @@ export function titleFor(page?: string): string {
19
20
  export const ORG_ID = `${SITE_URL}/#organization`;
20
21
 
21
22
  export function orgJsonLd() {
23
+ if (kit.seo.orgJsonLd) return kit.seo.orgJsonLd() as ReturnType<typeof generatedOrg>;
24
+ return generatedOrg();
25
+ }
26
+
27
+ function generatedOrg() {
22
28
  return {
23
29
  '@context': 'https://schema.org',
24
30
  '@type': 'Organization',
@@ -26,8 +32,8 @@ export function orgJsonLd() {
26
32
  name: SITE_NAME,
27
33
  ...(COMPANY ? { legalName: COMPANY } : {}),
28
34
  url: `${SITE_URL}/`,
29
- logo: abs(kit.seo.logo),
30
- ...(SOCIAL_PROFILES.length ? { sameAs: [...SOCIAL_PROFILES] } : {}),
35
+ logo: typeof kit.seo.logo === 'string' ? abs(kit.seo.logo) : kit.seo.logo,
36
+ ...(SOCIAL_PROFILES ? { sameAs: [...SOCIAL_PROFILES] } : {}),
31
37
  ...(PARENT_COMPANY_ID ? { parentOrganization: { '@type': 'Organization', '@id': PARENT_COMPANY_ID, name: PARENT_COMPANY_NAME, url: PARENT_COMPANY_URL } } : {}),
32
38
  ...(CONTACT_EMAIL ? { email: CONTACT_EMAIL } : {}),
33
39
  ...(CONTACT_PHONE_JSONLD ? { telephone: CONTACT_PHONE_JSONLD } : {}),
@@ -120,7 +126,7 @@ export function articleJsonLd(post: {
120
126
  inLanguage: 'en',
121
127
  ...(post.tags?.length ? { keywords: post.tags.map((t) => t.replace(/-/g, ' ')).join(', '), articleSection: post.tags[0].replace(/-/g, ' ') } : {}),
122
128
  ...(post.words ? { wordCount: post.words } : {}),
123
- about: { '@type': 'Thing', name: kit.blog.about },
129
+ ...(kit.blog.about ? { about: { '@type': 'Thing', name: kit.blog.about } } : {}),
124
130
  };
125
131
  }
126
132
 
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  import ChevronDown from '@lucide/astro/icons/chevron-down';
3
3
  import { render } from 'astro:content';
4
+ import blogImages from 'virtual:site-kit/blog-images';
4
5
  import { Image, getImage } from 'astro:assets';
5
6
  import { LICENCES } from '../../lib/blog-schema';
6
7
  import Base from '@site/layouts/Base.astro';
@@ -22,6 +23,7 @@ const { Content, headings } = await render(post);
22
23
  const toc = headings.filter((h) => h.depth === 2);
23
24
  const hasToc = toc.length >= 4;
24
25
  const minutes = readMinutes(post);
26
+ const relatedLabels = kit.blog.related ?? { products: 'Products in this article', industries: 'Industries', more: 'More insights' };
25
27
  const d = post.data;
26
28
  const path = `/blog/${post.id}`;
27
29
  // The post's first topic is its section in the breadcrumb trail.
@@ -31,7 +33,7 @@ const image = d.cover ? (await getImage({ src: d.cover, width: 1200, height: 630
31
33
  const credits = d.credits.filter((c) => !('own' in c));
32
34
  // Every credited image as an ImageObject with its licence, so search engines
33
35
  // show the right credit (and the Licensable badge) in image results.
34
- const files = import.meta.glob<{ default: ImageMetadata }>('/src/assets/blog/**/*.{jpg,jpeg,png,webp,avif}', { eager: true });
36
+ const files = blogImages as Record<string, { default: ImageMetadata }>;
35
37
  const imageObjects = await Promise.all(
36
38
  d.credits.map(async (c) => {
37
39
  const mod = files[`/src/assets/blog/${post.id}/${c.file}`];
@@ -144,9 +146,9 @@ const readNext = (next.length ? next : all.filter((p) => p.id !== post.id)).slic
144
146
  </article>
145
147
 
146
148
  <Related groups={[
147
- { h: 'Products in this article', items: productsForTags(d.tags) },
148
- { h: 'Industries', items: solutionsForTags(d.tags) },
149
- { 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 })) },
149
+ { h: relatedLabels.products, items: productsForTags(d.tags) },
150
+ { h: relatedLabels.industries, items: solutionsForTags(d.tags) },
151
+ { h: relatedLabels.more, 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 })) },
150
152
  ]} />
151
153
  <CtaBand />
152
154
  </Base>
@@ -11,6 +11,9 @@ import { PAGE_SIZE, allTags, byTag, tagLabel } from '../../lib/blog';
11
11
  import { breadcrumbJsonLd } from '../../lib/seo';
12
12
  import { kit } from '../../config';
13
13
 
14
+ // An optional component under the pager: the site's src/components/BlogIndexExtra.astro.
15
+ const extras = import.meta.glob<{ default: any }>('@site/components/BlogIndexExtra.astro', { eager: true });
16
+ const Extra = Object.values(extras)[0]?.default;
14
17
  const all = await posts();
15
18
  const tags = allTags(all.map((p) => ({ ...p, data: { ...p.data, draft: false } })));
16
19
  const last = Math.max(1, Math.ceil(all.length / PAGE_SIZE));
@@ -26,7 +29,7 @@ const sections = tags
26
29
  .sort((a, b) => b.items.length - a.items.length)
27
30
  .slice(0, 3);
28
31
  ---
29
- <Base title={kit.blog.label} description={kit.blog.description} path="/blog" jsonLd={[breadcrumbJsonLd([{ name: kit.blog.label, path: '/blog' }])]}>
32
+ <Base title={kit.blog.indexTitle ?? kit.blog.label} pageType={kit.blog.indexPageType} description={kit.blog.description} path="/blog" jsonLd={[breadcrumbJsonLd([{ name: kit.blog.label, path: '/blog' }]), ...(kit.blog.indexJsonLd?.(all.map((p) => ({ slug: p.id, title: p.data.title, description: p.data.description, date: p.data.date }))) ?? [])]}>
30
33
  <section class="front">
31
34
  <div class="wrap">
32
35
  <h1>{kit.blog.label}</h1>
@@ -70,6 +73,7 @@ const sections = tags
70
73
  </div>
71
74
 
72
75
  <Pager current={1} last={last} />
76
+ {Extra && <Extra />}
73
77
  </>
74
78
  ) : <p class="muted">The first posts are on their way.</p>}
75
79
  </div>
@@ -18,7 +18,7 @@ const path = `/blog/tag/${tag}`;
18
18
  // Topics with fewer than three posts stay out of search until they fill up.
19
19
  ---
20
20
  <Base
21
- title={`${label} articles`}
21
+ title={`${label} ${kit.blog.tagNoun ?? 'articles'}`}
22
22
  description={kit.blog.tagDescription(label)}
23
23
  path={path}
24
24
  noindex={items.length < 3}
@@ -12,18 +12,23 @@ const { Resvg } = createRequire(import.meta.url)('@resvg/resvg-js') as typeof im
12
12
  import { glossary } from '../../lib/glossary';
13
13
  import { SITE_NAME, SITE_URL, kit } from '../../config';
14
14
 
15
- const font = (w: number) => readFileSync(`node_modules/@fontsource/poppins/files/poppins-latin-${w}-normal.woff`);
16
15
  const { og } = kit;
17
- const mark = `data:image/svg+xml;base64,${Buffer.from(readFileSync(`public/${og.mark.file}`, 'utf8').replace(og.mark.from, og.mark.fill)).toString('base64')}`;
16
+ const face = og.font ?? { family: 'Poppins', package: 'poppins' };
17
+ const font = (w: number) => readFileSync(`node_modules/@fontsource/${face.package}/files/${face.package}-latin-${w}-normal.woff`);
18
+ const mark = og.mark.png
19
+ ? `data:image/png;base64,${readFileSync(`public/${og.mark.file}`).toString('base64')}`
20
+ : `data:image/svg+xml;base64,${Buffer.from(readFileSync(`public/${og.mark.file}`, 'utf8').replace(og.mark.from ?? '', og.mark.fill ?? '')).toString('base64')}`;
21
+ const markImg = { type: 'img', props: { src: mark, width: og.mark.width, height: og.mark.height } };
22
+ const plate = og.mark.plate;
18
23
 
19
24
  export async function getStaticPaths() {
20
25
  const posts = await getCollection('blog');
21
26
  const pages: { slug: string; title: string }[] = [
22
27
  ...og.pages(),
23
- { slug: 'glossary', title: kit.glossary.ogTitle },
28
+ ...(glossary.length ? [{ slug: 'glossary', title: kit.glossary.ogTitle }] : []),
24
29
  ...glossary.map((t) => ({ slug: `glossary/${t.slug}`, title: t.full ? `${t.term}: ${t.full}` : t.term })),
25
30
  ...posts.map((p) => ({ slug: `blog/${p.id}`, title: p.data.title })),
26
- ...[...new Set(posts.flatMap((p) => p.data.tags))].map((t) => ({ slug: `blog/tag/${t}`, title: `${t.replace(/-/g, ' ').replace(/^./, (c) => c.toUpperCase())} articles` })),
31
+ ...[...new Set(posts.flatMap((p) => p.data.tags))].map((t) => ({ slug: `blog/tag/${t}`, title: `${t.replace(/-/g, ' ').replace(/^./, (c) => c.toUpperCase())} ${kit.blog.tagNoun ?? 'articles'}` })),
27
32
  ];
28
33
  const n = Math.ceil(posts.length / 10);
29
34
  for (let i = 2; i <= n; i++) pages.push({ slug: `blog/page/${i}`, title: `${kit.blog.name}, page ${i}` });
@@ -36,15 +41,15 @@ export async function GET({ props }: APIContext) {
36
41
  {
37
42
  type: 'div',
38
43
  props: {
39
- style: { width: 1200, height: 630, display: 'flex', flexDirection: 'column', justifyContent: 'space-between', padding: 72, background: og.background, color: og.ink, fontFamily: 'Poppins' },
44
+ style: { width: 1200, height: 630, display: 'flex', flexDirection: 'column', justifyContent: 'space-between', padding: 72, background: og.background, color: og.ink, fontFamily: face.family },
40
45
  children: [
41
46
  {
42
47
  type: 'div',
43
48
  props: {
44
49
  style: { display: 'flex', alignItems: 'center', gap: 20 },
45
50
  children: [
46
- { type: 'img', props: { src: mark, width: og.mark.width, height: og.mark.height } },
47
- { type: 'div', props: { style: { fontSize: 40, fontWeight: 600 }, children: SITE_NAME } },
51
+ plate ? { type: 'div', props: { style: { display: 'flex', background: plate.background, borderRadius: plate.radius, padding: plate.padding }, children: [markImg] } } : markImg,
52
+ { type: 'div', props: { style: { fontSize: og.name?.size ?? 40, fontWeight: og.name?.weight ?? 600 }, children: og.name?.text ?? SITE_NAME } },
48
53
  ],
49
54
  },
50
55
  },
@@ -53,7 +58,7 @@ export async function GET({ props }: APIContext) {
53
58
  ],
54
59
  },
55
60
  },
56
- { width: 1200, height: 630, fonts: [{ name: 'Poppins', data: font(400), weight: 400 }, { name: 'Poppins', data: font(600), weight: 600 }] },
61
+ { width: 1200, height: 630, fonts: [{ name: face.family, data: font(400), weight: 400 }, { name: face.family, data: font(600), weight: 600 }] },
57
62
  );
58
63
  const png = new Resvg(svg).render().asPng();
59
64
  return new Response(png, { headers: { 'content-type': 'image/png' } });
@@ -162,6 +162,3 @@ button, input, select, textarea { font: inherit; color: inherit; }
162
162
  body { background: #FFFFFF; color: #000000; font-size: 12pt; }
163
163
  a { color: inherit; }
164
164
  }
165
-
166
- /* Blog: headings and post titles in the reading serif. */
167
- .blog-serif h1, .blog-serif h2, .blog-serif h3 { font-family: 'Source Serif 4 Variable', 'Serif Fallback', Georgia, serif; font-weight: 600; }
@@ -0,0 +1,2 @@
1
+ /* Blog: headings and post titles in the reading serif. */
2
+ .blog-serif h1, .blog-serif h2, .blog-serif h3 { font-family: 'Source Serif 4 Variable', 'Serif Fallback', Georgia, serif; font-weight: 600; }
@@ -0,0 +1,4 @@
1
+ declare module 'virtual:site-kit/blog-images' {
2
+ const images: Record<string, { default: unknown }>;
3
+ export default images;
4
+ }