@ninjainfosys/site-kit 0.2.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 +1 -1
- package/src/components/seo/Seo.astro +6 -2
- package/src/components/site/Header.astro +8 -7
- package/src/config.ts +1 -2
- package/src/contract.ts +32 -7
- package/src/layouts/Base.astro +4 -3
- package/src/lib/blog.ts +5 -2
- package/src/lib/seo.ts +8 -2
- package/src/pages/blog/[slug].astro +4 -3
- package/src/pages/blog/index.astro +5 -1
- package/src/pages/blog/tag/[tag].astro +1 -1
- package/src/pages/og/[...slug].png.ts +8 -4
package/package.json
CHANGED
|
@@ -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
|
|
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} />
|
|
@@ -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=
|
|
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,10 +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
|
-
{logo.
|
|
27
|
-
?
|
|
28
|
-
:
|
|
29
|
-
|
|
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></>}</>}
|
|
30
31
|
</a>
|
|
31
32
|
|
|
32
33
|
<nav class="nav-wide" aria-label="Main">
|
|
@@ -39,7 +40,7 @@ const current = (href: string) => (path === href || path.startsWith(`${href}/`)
|
|
|
39
40
|
<div class="wrap mega-grid">
|
|
40
41
|
<ul class="mega-links">
|
|
41
42
|
{g.links.map((l) => (
|
|
42
|
-
<li><a href={l.href} aria-current={current(l.href)}
|
|
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>
|
|
43
44
|
))}
|
|
44
45
|
</ul>
|
|
45
46
|
<a class="mega-feature" href={g.feature.href}>
|
package/src/config.ts
CHANGED
|
@@ -34,14 +34,13 @@ export const kit: KitConfig = {
|
|
|
34
34
|
rssDescription: `Guides and notes from ${SITE_NAME}.`,
|
|
35
35
|
pageDescription: (n, last) => `Older ${SITE_NAME} guides. Page ${n} of ${last}.`,
|
|
36
36
|
tagDescription: (label) => `${SITE_NAME} articles about ${label.toLowerCase()}.`,
|
|
37
|
-
about: SITE_NAME,
|
|
38
37
|
imageCredit: SITE_NAME,
|
|
39
38
|
...siteKit.blog,
|
|
40
39
|
},
|
|
41
40
|
seo: { hreflang: 'en', ogLocale: 'en_US', logo: '/favicon.svg', ...siteKit.seo },
|
|
42
41
|
head: { preloadFonts: [], icons: [], ...siteKit.head },
|
|
43
42
|
header: siteKit.header,
|
|
44
|
-
footer: siteKit.footer,
|
|
43
|
+
footer: siteKit.footer as KitConfig['footer'],
|
|
45
44
|
cta: siteKit.cta,
|
|
46
45
|
og: siteKit.og,
|
|
47
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 {
|
|
@@ -71,9 +75,9 @@ export interface HeaderGroup {
|
|
|
71
75
|
export interface HeaderConfig {
|
|
72
76
|
homeLabel: string;
|
|
73
77
|
/** `text` sets a wordmark beside the logo images. */
|
|
74
|
-
logo: { light: string; dark: string; alt: string; width: number; height: number; text?: string };
|
|
78
|
+
logo: { light: string; dark: string; alt: string; width: number; height: number; text?: string; kind?: 'lockup' | 'mark' };
|
|
75
79
|
/** The thin strip above the bar. `text` is plain, `mono` is set in the mono face. */
|
|
76
|
-
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 };
|
|
77
81
|
groups: HeaderGroup[];
|
|
78
82
|
/** Links in the bar after the groups. */
|
|
79
83
|
plain: HeaderLink[];
|
|
@@ -102,7 +106,7 @@ export interface OgConfig {
|
|
|
102
106
|
/** Name beside the mark; default is SITE_NAME at 40px, weight 600. */
|
|
103
107
|
name?: { text: string; size: number; weight: number };
|
|
104
108
|
/** SVG in public/ drawn beside the site name; `from` is the fill replaced by `fill` (leave both out to use it as is). */
|
|
105
|
-
mark: { file: string; from?: string; fill?: string; width: number; height: number };
|
|
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 } };
|
|
106
110
|
/** Pages the site owns: static pages, products, solutions. The kit adds blog, tag and glossary cards. */
|
|
107
111
|
pages: () => { slug: string; title: string }[];
|
|
108
112
|
}
|
|
@@ -122,15 +126,35 @@ export interface KitConfig {
|
|
|
122
126
|
rssDescription: string;
|
|
123
127
|
pageDescription: (n: number, last: number) => string;
|
|
124
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[];
|
|
125
138
|
/** Schema.org `about` of every post. */
|
|
126
|
-
about
|
|
139
|
+
/** Schema.org `about` of every post; left out when not set. */
|
|
140
|
+
about?: string;
|
|
127
141
|
/** Credit line on the site's own images. */
|
|
128
142
|
imageCredit: string;
|
|
129
143
|
};
|
|
130
144
|
seo: {
|
|
131
145
|
hreflang: string;
|
|
132
146
|
ogLocale: string;
|
|
133
|
-
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;
|
|
134
158
|
contactPoint?: { contactType: string; areaServed: string; availableLanguage: string[] };
|
|
135
159
|
};
|
|
136
160
|
head: {
|
|
@@ -140,7 +164,7 @@ export interface KitConfig {
|
|
|
140
164
|
manifest?: string;
|
|
141
165
|
};
|
|
142
166
|
header: HeaderConfig;
|
|
143
|
-
footer
|
|
167
|
+
footer?: FooterConfig;
|
|
144
168
|
cta: { heading: string; actions: { href: string; label: string; class: string }[] };
|
|
145
169
|
og: OgConfig;
|
|
146
170
|
glossary: {
|
|
@@ -166,7 +190,8 @@ export interface SiteKit {
|
|
|
166
190
|
head?: Partial<KitConfig['head']>;
|
|
167
191
|
glossary?: Partial<KitConfig['glossary']>;
|
|
168
192
|
header: HeaderConfig;
|
|
169
|
-
footer
|
|
193
|
+
/** Leave out when the site renders its own footer in the layout's footer slot. */
|
|
194
|
+
footer?: FooterConfig;
|
|
170
195
|
cta: KitConfig['cta'];
|
|
171
196
|
og: OgConfig;
|
|
172
197
|
llms: KitConfig['llms'];
|
package/src/layouts/Base.astro
CHANGED
|
@@ -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}
|
|
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
|
-
|
|
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
|
|
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,7 +32,7 @@ export function orgJsonLd() {
|
|
|
26
32
|
name: SITE_NAME,
|
|
27
33
|
...(COMPANY ? { legalName: COMPANY } : {}),
|
|
28
34
|
url: `${SITE_URL}/`,
|
|
29
|
-
logo: abs(kit.seo.logo),
|
|
35
|
+
logo: typeof kit.seo.logo === 'string' ? abs(kit.seo.logo) : kit.seo.logo,
|
|
30
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 } : {}),
|
|
@@ -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
|
|
|
@@ -23,6 +23,7 @@ const { Content, headings } = await render(post);
|
|
|
23
23
|
const toc = headings.filter((h) => h.depth === 2);
|
|
24
24
|
const hasToc = toc.length >= 4;
|
|
25
25
|
const minutes = readMinutes(post);
|
|
26
|
+
const relatedLabels = kit.blog.related ?? { products: 'Products in this article', industries: 'Industries', more: 'More insights' };
|
|
26
27
|
const d = post.data;
|
|
27
28
|
const path = `/blog/${post.id}`;
|
|
28
29
|
// The post's first topic is its section in the breadcrumb trail.
|
|
@@ -145,9 +146,9 @@ const readNext = (next.length ? next : all.filter((p) => p.id !== post.id)).slic
|
|
|
145
146
|
</article>
|
|
146
147
|
|
|
147
148
|
<Related groups={[
|
|
148
|
-
{ h:
|
|
149
|
-
{ h:
|
|
150
|
-
{ h:
|
|
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 })) },
|
|
151
152
|
]} />
|
|
152
153
|
<CtaBand />
|
|
153
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}
|
|
@@ -15,16 +15,20 @@ import { SITE_NAME, SITE_URL, kit } from '../../config';
|
|
|
15
15
|
const { og } = kit;
|
|
16
16
|
const face = og.font ?? { family: 'Poppins', package: 'poppins' };
|
|
17
17
|
const font = (w: number) => readFileSync(`node_modules/@fontsource/${face.package}/files/${face.package}-latin-${w}-normal.woff`);
|
|
18
|
-
const mark =
|
|
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;
|
|
19
23
|
|
|
20
24
|
export async function getStaticPaths() {
|
|
21
25
|
const posts = await getCollection('blog');
|
|
22
26
|
const pages: { slug: string; title: string }[] = [
|
|
23
27
|
...og.pages(),
|
|
24
|
-
{ slug: 'glossary', title: kit.glossary.ogTitle },
|
|
28
|
+
...(glossary.length ? [{ slug: 'glossary', title: kit.glossary.ogTitle }] : []),
|
|
25
29
|
...glossary.map((t) => ({ slug: `glossary/${t.slug}`, title: t.full ? `${t.term}: ${t.full}` : t.term })),
|
|
26
30
|
...posts.map((p) => ({ slug: `blog/${p.id}`, title: p.data.title })),
|
|
27
|
-
...[...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'}` })),
|
|
28
32
|
];
|
|
29
33
|
const n = Math.ceil(posts.length / 10);
|
|
30
34
|
for (let i = 2; i <= n; i++) pages.push({ slug: `blog/page/${i}`, title: `${kit.blog.name}, page ${i}` });
|
|
@@ -44,7 +48,7 @@ export async function GET({ props }: APIContext) {
|
|
|
44
48
|
props: {
|
|
45
49
|
style: { display: 'flex', alignItems: 'center', gap: 20 },
|
|
46
50
|
children: [
|
|
47
|
-
{ type: '
|
|
51
|
+
plate ? { type: 'div', props: { style: { display: 'flex', background: plate.background, borderRadius: plate.radius, padding: plate.padding }, children: [markImg] } } : markImg,
|
|
48
52
|
{ type: 'div', props: { style: { fontSize: og.name?.size ?? 40, fontWeight: og.name?.weight ?? 600 }, children: og.name?.text ?? SITE_NAME } },
|
|
49
53
|
],
|
|
50
54
|
},
|