@digitaldefiance/gitdash-fonts 0.0.0-stage → 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/README.md CHANGED
@@ -1,3 +1,61 @@
1
- # Temporary Holding Version
1
+ # @digitaldefiance/gitdash-fonts
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Choose Google Fonts in the studio and serve them from your own site, for [EmDash](https://github.com/emdash-cms/emdash) and [GitDash](https://github.com/Digital-Defiance/gitdash) sites. It covers the main features of the WordPress plugin Fonts Plugin: font choice, per-element typography, and local hosting so visitors make no requests to Google.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install @digitaldefiance/gitdash-fonts
9
+ npx gitdash-fonts init # adds a "fonts" collection with one entry to content/
10
+ ```
11
+
12
+ Add the component to your layout's `<head>`, after your other stylesheets:
13
+
14
+ ```astro
15
+ ---
16
+ import FontStyles from "@digitaldefiance/gitdash-fonts/FontStyles.astro";
17
+ ---
18
+ <FontStyles />
19
+ ```
20
+
21
+ Run `gitdash-fonts build` before `astro build`:
22
+
23
+ ```json
24
+ "build": "... && gitdash-fonts build && astro build && ..."
25
+ ```
26
+
27
+ ## Use
28
+
29
+ Open the **Fonts** collection in the studio, edit the entry, and commit. The next build downloads the files from Google Fonts into `public/fonts/` and writes `public/fonts/fonts.css`. The published site loads only your own files.
30
+
31
+ | Field | Example |
32
+ | --- | --- |
33
+ | Body font, Heading font | `Lora`, `Playfair Display` (any Google Fonts family; headings default to the body font) |
34
+ | Weights to download | `400,700` |
35
+ | Character sets | `latin, latin-ext` (also cyrillic, greek, vietnamese) |
36
+ | Body weight, heading weight | `400`, `700` |
37
+ | Base font size, line height, letter spacing | `18px`, `1.6`, `0.01em` |
38
+ | Body text color, heading color | `#222`, `#0a3d62` |
39
+ | Heading case | none, uppercase, lowercase, capitalize |
40
+ | Adobe Fonts web project ID, Adobe fonts | `abc1def`, `proxima-nova`: list the fonts from Adobe, then use them in the font fields above |
41
+ | Other elements | one per line: `selector \| Font family \| weight`, such as `blockquote \| Lora \| 400` |
42
+
43
+ The CSS variables `--gitdash-body-font` and `--gitdash-heading-font` are also set, for use in your own styles. The older names `--ghdash-body-font` and `--ghdash-heading-font` still work.
44
+
45
+ If your theme sets fonts with a more specific selector (a class, for example), the settings above won't override it. Use the "Other elements" field to target that selector.
46
+
47
+ Values are checked before they are written to the stylesheet. A font name, size, color or selector that doesn't look valid is skipped with a warning in the build log.
48
+
49
+ ## Adobe Fonts
50
+
51
+ Adobe's licence doesn't allow self-hosting, so fonts from an Adobe web project load from `use.typekit.net`, and visitors make a request to Adobe. Google fonts are still served from your site. Create a web project at fonts.adobe.com, add the domains your site uses, and copy the project ID into "Adobe Fonts web project ID". List the Adobe font names (as shown in the project's CSS, like `proxima-nova`) in "Fonts that come from Adobe". If you already ran `gitdash-fonts init`, run it again to add the two new fields.
52
+
53
+ ## Your own font files
54
+
55
+ Put `.woff2`, `.woff`, `.ttf` or `.otf` files in a `custom-fonts/` folder at the root of the site. You can upload them on github.com, since the studio can't take font files. Name each file after the font and weight: `Acme Sans-400.woff2`, `Acme Sans-700-italic.woff2`. The build copies the files to `public/fonts/` and writes the `@font-face` rules. Then use the name (`Acme Sans`) in the Fonts entry like any other font. Make sure you are licensed to publish the files, because they will be public in your repo and on your site.
56
+
57
+ ## Not included
58
+
59
+ Choosing fonts from a preview list. Italic styles are not downloaded.
60
+
61
+ MIT licensed.
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ // gitdash-fonts init adds a "fonts" collection with one entry to a GitDash site's content/ folder
3
+ // gitdash-fonts build downloads the chosen Google Fonts into public/fonts and writes public/fonts/fonts.css
4
+ const cmd = process.argv[2];
5
+ if (cmd === "init") await import("../lib/init.mjs");
6
+ else if (cmd === "build") await import("../lib/build.mjs");
7
+ else {
8
+ console.error("usage: gitdash-fonts init | build");
9
+ process.exit(1);
10
+ }
@@ -0,0 +1,5 @@
1
+ ---
2
+ const base = import.meta.env.BASE_URL.replace(/\/$/, "");
3
+ ---
4
+
5
+ <link rel="stylesheet" href={`${base}/fonts/fonts.css`} />
package/lib/build.mjs ADDED
@@ -0,0 +1,65 @@
1
+ import { copyFileSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync, existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { adobeImport, customFaceCss, families, parseCustomFontName, fileName, fontFaceCss, googleCssUrl, parseGoogleCss, readSettings, rulesCss } from "./css.mjs";
4
+
5
+ const UA = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0 Safari/537.36";
6
+ const out = "public/fonts";
7
+ const dir = "content/ec_fonts";
8
+
9
+ function findRow() {
10
+ if (!existsSync(dir)) return undefined;
11
+ return readdirSync(dir)
12
+ .map((f) => JSON.parse(readFileSync(join(dir, f), "utf8")))
13
+ .filter((r) => r.status === "published" && !r.deleted_at)
14
+ .sort((a, b) => String(a.created_at).localeCompare(String(b.created_at)))[0];
15
+ }
16
+
17
+ async function get(url, binary) {
18
+ const res = await fetch(url, { headers: { "user-agent": UA } });
19
+ if (!res.ok) return { status: res.status };
20
+ return { status: 200, body: binary ? Buffer.from(await res.arrayBuffer()) : await res.text() };
21
+ }
22
+
23
+ rmSync(out, { recursive: true, force: true });
24
+ const row = findRow();
25
+ if (!row) {
26
+ console.log("gitdash-fonts: no published entry in the fonts collection, skipping");
27
+ process.exit(0);
28
+ }
29
+ const { settings, warnings } = readSettings(row);
30
+ for (const w of warnings) console.warn("gitdash-fonts: WARNING:", w);
31
+
32
+ mkdirSync(out, { recursive: true });
33
+ const customDir = "custom-fonts";
34
+ const custom = [];
35
+ if (existsSync(customDir)) {
36
+ for (const file of readdirSync(customDir)) {
37
+ const face = parseCustomFontName(file);
38
+ if (!face) {
39
+ if (!file.startsWith(".")) console.warn(`gitdash-fonts: WARNING: ${customDir}/${file} is not named like "Family Name-400.woff2" and was skipped`);
40
+ continue;
41
+ }
42
+ copyFileSync(join(customDir, file), join(out, `custom-${file}`));
43
+ custom.push(face);
44
+ }
45
+ if (custom.length) console.log(`gitdash-fonts: ${custom.length} font file(s) from ${customDir}/`);
46
+ }
47
+ const faces = [];
48
+ for (const family of families(settings, custom.map((f) => f.family))) {
49
+ let res = await get(googleCssUrl(family, settings.weights));
50
+ if (res.status === 400) res = await get(googleCssUrl(family));
51
+ if (res.status !== 200) {
52
+ console.warn(`gitdash-fonts: WARNING: could not find "${family}" on Google Fonts (HTTP ${res.status}); skipped`);
53
+ continue;
54
+ }
55
+ const parsed = parseGoogleCss(res.body).filter((f) => settings.subsets.includes(f.subset));
56
+ for (const face of parsed) {
57
+ const file = await get(face.url, true);
58
+ if (file.status !== 200) throw new Error(`could not download ${face.url}`);
59
+ writeFileSync(join(out, fileName(face)), file.body);
60
+ faces.push(face);
61
+ }
62
+ console.log(`gitdash-fonts: ${family}: ${parsed.length} file(s)`);
63
+ }
64
+ writeFileSync(join(out, "fonts.css"), `${adobeImport(settings)}${fontFaceCss(faces)}\n${custom.length ? `${customFaceCss(custom)}\n` : ""}${rulesCss(settings)}\n`);
65
+ console.log(`gitdash-fonts: wrote ${out}/fonts.css with ${faces.length} font file(s)`);
package/lib/css.mjs ADDED
@@ -0,0 +1,186 @@
1
+ // Pure helpers: validate the settings, parse Google's CSS, and write the rules that apply the fonts.
2
+
3
+ const FAMILY = /^[A-Za-z0-9][A-Za-z0-9 -]{0,60}$/;
4
+ const COLOR = /^(#[0-9a-fA-F]{3,8}|[a-zA-Z]{3,20}|(rgb|hsl)a?\([0-9.,%\s/]+\))$/;
5
+ const LENGTH = /^[0-9.]+(px|rem|em|%)?$/;
6
+ const ADOBE_KIT = /^[a-zA-Z0-9]{5,12}$/;
7
+ const ADOBE_FAMILY = /^[a-zA-Z0-9][a-zA-Z0-9 -]{0,60}$/;
8
+ const SELECTOR = /^[^{};@\\<>]+$/;
9
+ export const SUBSETS = ["latin", "latin-ext", "cyrillic", "cyrillic-ext", "greek", "greek-ext", "vietnamese"];
10
+ export const TRANSFORMS = ["none", "uppercase", "lowercase", "capitalize"];
11
+
12
+ const text = (v) => (typeof v === "string" ? v.trim() : "");
13
+
14
+ export function readSettings(row) {
15
+ const warnings = [];
16
+ const pick = (name, value, test, label) => {
17
+ if (!value) return undefined;
18
+ if (test(value)) return value;
19
+ warnings.push(`${label} "${value}" is not valid and was ignored`);
20
+ return undefined;
21
+ };
22
+ const family = (name, label) => pick(name, text(row[name]), (v) => FAMILY.test(v), label);
23
+ const weights = [
24
+ ...new Set(
25
+ text(row.weights || "400,700")
26
+ .split(/[,\s]+/)
27
+ .filter(Boolean),
28
+ ),
29
+ ].filter((w) => {
30
+ const ok = /^[1-9]00$/.test(w);
31
+ if (!ok) warnings.push(`weight "${w}" is not valid and was ignored`);
32
+ return ok;
33
+ });
34
+ const subsets = text(row.subsets || "latin")
35
+ .split(/[,\s]+/)
36
+ .filter((s) => SUBSETS.includes(s));
37
+ const custom = text(row.custom_selectors)
38
+ .split("\n")
39
+ .map((l) => l.trim())
40
+ .filter(Boolean)
41
+ .flatMap((line) => {
42
+ const [selector, fam, weight] = line.split("|").map((p) => p.trim());
43
+ if (!selector || !SELECTOR.test(selector) || !FAMILY.test(fam ?? "")) {
44
+ warnings.push(`custom selector line "${line}" is not valid and was ignored`);
45
+ return [];
46
+ }
47
+ return [{ selector, family: fam, weight: /^[1-9]00$/.test(weight ?? "") ? weight : undefined }];
48
+ });
49
+ const transform = text(row.heading_transform);
50
+ const adobeKit = pick("adobe_kit", text(row.adobe_kit), (v) => ADOBE_KIT.test(v), "Adobe project ID");
51
+ const adobeFamilies = text(row.adobe_families)
52
+ .split(",")
53
+ .map((f) => f.trim())
54
+ .filter(Boolean)
55
+ .filter((f) => {
56
+ const ok = ADOBE_FAMILY.test(f);
57
+ if (!ok) warnings.push(`Adobe font "${f}" is not valid and was ignored`);
58
+ return ok;
59
+ });
60
+ return {
61
+ settings: {
62
+ headingFont: family("heading_font", "heading font"),
63
+ bodyFont: family("body_font", "body font"),
64
+ adobeKit,
65
+ adobeFamilies,
66
+ weights: weights.length ? weights : ["400", "700"],
67
+ subsets: subsets.length ? subsets : ["latin"],
68
+ headingWeight: pick("heading_weight", text(row.heading_weight), (v) => /^[1-9]00$/.test(v), "heading weight"),
69
+ bodyWeight: pick("body_weight", text(row.body_weight), (v) => /^[1-9]00$/.test(v), "body weight"),
70
+ baseSize: pick("base_size", text(row.base_size), (v) => LENGTH.test(v), "base size"),
71
+ lineHeight: pick("line_height", text(row.line_height), (v) => /^[0-9.]+$/.test(v), "line height"),
72
+ letterSpacing: pick("letter_spacing", text(row.letter_spacing), (v) => /^-?[0-9.]+(px|em|rem)$/.test(v), "letter spacing"),
73
+ headingColor: pick("heading_color", text(row.heading_color), (v) => COLOR.test(v), "heading color"),
74
+ bodyColor: pick("body_color", text(row.body_color), (v) => COLOR.test(v), "body color"),
75
+ headingTransform: TRANSFORMS.includes(transform) ? transform : undefined,
76
+ custom,
77
+ },
78
+ warnings,
79
+ };
80
+ }
81
+
82
+ const FORMATS = { woff2: "woff2", woff: "woff", ttf: "truetype", otf: "opentype" };
83
+
84
+ // "Acme Sans-700-italic.woff2" -> family "Acme Sans", weight 700, italic. Returns undefined for anything else.
85
+ export function parseCustomFontName(file) {
86
+ const m = /^([A-Za-z0-9][A-Za-z0-9 ]{0,60})-([1-9]00)(-italic)?\.(woff2|woff|ttf|otf)$/.exec(file);
87
+ if (!m) return undefined;
88
+ return { file, family: m[1], weight: m[2], style: m[3] ? "italic" : "normal", format: FORMATS[m[4]] };
89
+ }
90
+
91
+ export const customFaceCss = (faces) =>
92
+ faces
93
+ .map(
94
+ (f) =>
95
+ `@font-face{font-family:'${f.family}';font-style:${f.style};font-weight:${f.weight};font-display:swap;src:url(./custom-${encodeURIComponent(f.file)}) format('${f.format}');}`,
96
+ )
97
+ .join("\n");
98
+
99
+ // Fonts that come from Google, which are downloaded and served from the site.
100
+ export function families(settings, customFamilies = []) {
101
+ const adobe = new Set([...settings.adobeFamilies, ...customFamilies].map((f) => f.toLowerCase()));
102
+ return [...new Set([settings.headingFont, settings.bodyFont, ...settings.custom.map((c) => c.family)].filter(Boolean))].filter(
103
+ (f) => !adobe.has(f.toLowerCase()),
104
+ );
105
+ }
106
+
107
+ // Adobe's licence doesn't allow self-hosting, so their stylesheet is loaded from Adobe.
108
+ export function adobeImport(settings) {
109
+ return settings.adobeKit ? `@import url("https://use.typekit.net/${settings.adobeKit}.css");\n` : "";
110
+ }
111
+
112
+ export function googleCssUrl(family, weights) {
113
+ const name = family.replace(/ /g, "+");
114
+ return weights?.length
115
+ ? `https://fonts.googleapis.com/css2?family=${name}:wght@${[...weights].sort().join(";")}&display=swap`
116
+ : `https://fonts.googleapis.com/css2?family=${name}&display=swap`;
117
+ }
118
+
119
+ // Google's CSS puts a /* subset */ comment before each @font-face.
120
+ export function parseGoogleCss(css) {
121
+ const faces = [];
122
+ const re = /\/\*\s*([a-z-]+)\s*\*\/\s*@font-face\s*\{([^}]*)\}/g;
123
+ for (const m of css.matchAll(re)) {
124
+ const body = m[2];
125
+ const get = (prop) => new RegExp(`${prop}:\\s*([^;]+);`).exec(body)?.[1].trim();
126
+ const url = /url\((https:\/\/fonts\.gstatic\.com\/[^)]+\.woff2)\)/.exec(body)?.[1];
127
+ const family = get("font-family")?.replace(/['"]/g, "");
128
+ if (!url || !family) continue;
129
+ faces.push({
130
+ subset: m[1],
131
+ family,
132
+ style: get("font-style") ?? "normal",
133
+ weight: get("font-weight") ?? "400",
134
+ range: get("unicode-range"),
135
+ url,
136
+ });
137
+ }
138
+ return faces;
139
+ }
140
+
141
+ export const fileName = (face) =>
142
+ `${face.family.toLowerCase().replace(/[^a-z0-9]+/g, "-")}-${face.style}-${face.weight.replace(/\s+/g, "-")}-${face.subset}.woff2`;
143
+
144
+ export function fontFaceCss(faces) {
145
+ return faces
146
+ .map(
147
+ (f) =>
148
+ `@font-face{font-family:'${f.family}';font-style:${f.style};font-weight:${f.weight};font-display:swap;src:url(./${fileName(f)}) format('woff2');${f.range ? `unicode-range:${f.range};` : ""}}`,
149
+ )
150
+ .join("\n");
151
+ }
152
+
153
+ export function rulesCss(s) {
154
+ const stack = (f) => `'${f}',system-ui,sans-serif`;
155
+ const decl = (pairs) =>
156
+ pairs
157
+ .filter(([, v]) => v)
158
+ .map(([k, v]) => `${k}:${v}`)
159
+ .join(";");
160
+ const out = [];
161
+ const root = decl([
162
+ ...["gitdash", "ghdash"].flatMap((p) => [
163
+ [`--${p}-body-font`, s.bodyFont && stack(s.bodyFont)],
164
+ [`--${p}-heading-font`, (s.headingFont || s.bodyFont) && stack(s.headingFont || s.bodyFont)],
165
+ ]),
166
+ ]);
167
+ if (root) out.push(`:root{${root}}`);
168
+ const body = decl([
169
+ ["font-family", s.bodyFont && stack(s.bodyFont)],
170
+ ["font-weight", s.bodyWeight],
171
+ ["font-size", s.baseSize],
172
+ ["line-height", s.lineHeight],
173
+ ["color", s.bodyColor],
174
+ ["letter-spacing", s.letterSpacing],
175
+ ]);
176
+ if (body) out.push(`body{${body}}`);
177
+ const heading = decl([
178
+ ["font-family", s.headingFont && stack(s.headingFont)],
179
+ ["font-weight", s.headingWeight],
180
+ ["color", s.headingColor],
181
+ ["text-transform", s.headingTransform],
182
+ ]);
183
+ if (heading) out.push(`h1,h2,h3,h4,h5,h6{${heading}}`);
184
+ for (const c of s.custom) out.push(`${c.selector}{${decl([["font-family", stack(c.family)], ["font-weight", c.weight]])}}`);
185
+ return out.join("\n");
186
+ }
package/lib/init.mjs ADDED
@@ -0,0 +1,96 @@
1
+ // gitdash-fonts init: adds the "fonts" collection and one entry to content/ through the browser API.
2
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
3
+ import { createRequire } from "node:module";
4
+ import { dirname, join, resolve } from "node:path";
5
+ import { pathToFileURL } from "node:url";
6
+ import { spawnSync } from "node:child_process";
7
+
8
+ // The adapter was called ghdash-pages before the GitDash rename.
9
+ const ADAPTERS = ["gitdash-pages", "ghdash-pages"];
10
+ const pagesDir = ADAPTERS.map((n) => resolve(`node_modules/@digitaldefiance/${n}`)).find((d) => existsSync(d)) ?? resolve("node_modules/@digitaldefiance/gitdash-pages");
11
+ const bin = ADAPTERS.map((n) => join(pagesDir, `bin/${n}.mjs`)).find((f) => existsSync(f));
12
+ for (const cmd of ["build-db", "fetch-browser-api", "studio-assets"]) {
13
+ const r = spawnSync(process.execPath, [bin, cmd], { stdio: "inherit" });
14
+ if (r.status !== 0) process.exit(r.status ?? 1);
15
+ }
16
+ const require = createRequire(resolve("package.json"));
17
+ const sqlite3InitModule = (await import(pathToFileURL(require.resolve("@sqlite.org/sqlite-wasm")).href)).default;
18
+ const api = await import(pathToFileURL(resolve("public/studio-api/entry.js")).href);
19
+ const studioDir = join(pagesDir, "studio");
20
+ const { openDb } = await import(pathToFileURL(join(studioDir, "load-db.js")).href);
21
+ const { snapshot, filesFromContent, diffFiles } = await import(pathToFileURL(join(studioDir, "tray.js")).href);
22
+
23
+ const sqlite = await sqlite3InitModule({ print() {}, printErr() {} });
24
+ const content = JSON.parse(readFileSync("public/studio-data/content.json", "utf8"));
25
+ const { db: raw, database, freshNames } = openDb(sqlite, readFileSync("public/studio-data/empty.db"), content);
26
+ const baseFiles = filesFromContent(content);
27
+ const db = new api.Kysely({ dialect: new api.SqliteDialect({ database }) });
28
+ const fetchApi = api.createBrowserApi({ db, apiBase: "/_api", user: { id: "team", email: "team@users.noreply.github.com", name: "Team" } });
29
+ const call = async (method, path, body) => {
30
+ const res = await fetchApi(`https://team.local/_api${path}`, {
31
+ method,
32
+ headers: { "content-type": "application/json", "x-emdash-request": "1" },
33
+ body: body && JSON.stringify(body),
34
+ });
35
+ const json = await res.json();
36
+ if (!json.success) throw new Error(`${method} ${path}: ${json.error?.message}`);
37
+ return json;
38
+ };
39
+
40
+ const have = raw.selectValue("select count(*) from _emdash_collections where slug = 'fonts'");
41
+ if (!have) {
42
+ await call("POST", "/schema/collections", {
43
+ slug: "fonts",
44
+ label: "Fonts",
45
+ labelSingular: "Font settings",
46
+ supports: ["drafts", "revisions"],
47
+ });
48
+ }
49
+ {
50
+ const weight = (slug, label) => ({ slug, label, type: "select", validation: { options: ["100", "200", "300", "400", "500", "600", "700", "800", "900"] } });
51
+ const fields = [
52
+ { slug: "title", label: "Name", type: "string", required: true },
53
+ { slug: "body_font", label: "Body font (Google Fonts family, e.g. Inter)", type: "string" },
54
+ { slug: "heading_font", label: "Heading font (leave empty to use the body font)", type: "string" },
55
+ { slug: "weights", label: "Weights to download (e.g. 400,700)", type: "string" },
56
+ { slug: "subsets", label: "Character sets (latin, latin-ext, cyrillic, greek, vietnamese)", type: "string" },
57
+ weight("body_weight", "Body weight"),
58
+ weight("heading_weight", "Heading weight"),
59
+ { slug: "base_size", label: "Base font size (e.g. 18px or 1.125rem)", type: "string" },
60
+ { slug: "line_height", label: "Line height (e.g. 1.6)", type: "string" },
61
+ { slug: "letter_spacing", label: "Letter spacing (e.g. 0.01em)", type: "string" },
62
+ { slug: "body_color", label: "Body text color", type: "string" },
63
+ { slug: "heading_color", label: "Heading color", type: "string" },
64
+ { slug: "heading_transform", label: "Heading case", type: "select", validation: { options: ["none", "uppercase", "lowercase", "capitalize"] } },
65
+ { slug: "adobe_kit", label: "Adobe Fonts web project ID (optional; loads from Adobe, not your site)", type: "string" },
66
+ { slug: "adobe_families", label: "Fonts that come from Adobe, comma separated (e.g. proxima-nova)", type: "string" },
67
+ { slug: "custom_selectors", label: "Other elements: one per line as selector | Font family | weight", type: "text" },
68
+ ];
69
+ const known = (slug) =>
70
+ raw.selectValue(
71
+ "select count(*) from _emdash_fields f join _emdash_collections c on c.id = f.collection_id where c.slug = 'fonts' and f.slug = ?",
72
+ [slug],
73
+ ) > 0;
74
+ for (const f of fields) if (!known(f.slug)) await call("POST", "/schema/collections/fonts/fields", f);
75
+ }
76
+
77
+ const exists = raw.selectValue("select count(*) from ec_fonts where deleted_at is null");
78
+ if (!exists) {
79
+ const made = await call("POST", "/content/fonts", {
80
+ data: { title: "Site fonts", body_font: "Inter", heading_font: "Inter", weights: "400,700", subsets: "latin", heading_weight: "700" },
81
+ slug: "site-fonts",
82
+ status: "draft",
83
+ });
84
+ await call("POST", `/content/fonts/${made.data.item.id}/publish`, {});
85
+ }
86
+
87
+ let written = 0;
88
+ const after = snapshot(raw, freshNames);
89
+ for (const change of diffFiles(baseFiles, after)) {
90
+ const text = after.get(change.path);
91
+ if (text === undefined) continue;
92
+ mkdirSync(dirname(join("content", change.path)), { recursive: true });
93
+ writeFileSync(join("content", change.path), text);
94
+ written++;
95
+ }
96
+ console.log(`wrote ${written} file(s) in content/`);
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@digitaldefiance/gitdash-fonts",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.0",
4
+ "description": "Choose Google Fonts in the studio and serve them from your own site, for EmDash and GitDash.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/Digital-Defiance/gitdash-plugins.git",
10
+ "directory": "packages/fonts"
11
+ },
12
+ "homepage": "https://github.com/Digital-Defiance/gitdash-plugins/tree/main/packages/fonts#readme",
13
+ "keywords": [
14
+ "emdash",
15
+ "gitdash",
16
+ "astro",
17
+ "fonts",
18
+ "google-fonts"
19
+ ],
20
+ "bin": {
21
+ "gitdash-fonts": "bin/gitdash-fonts.mjs",
22
+ "ghdash-fonts": "bin/gitdash-fonts.mjs"
23
+ },
24
+ "exports": {
25
+ "./FontStyles.astro": "./components/FontStyles.astro",
26
+ "./css": "./lib/css.mjs",
27
+ "./package.json": "./package.json"
28
+ },
29
+ "files": [
30
+ "bin",
31
+ "lib",
32
+ "components",
33
+ "README.md"
34
+ ],
35
+ "scripts": {
36
+ "test": "node --test test/*.test.mjs"
37
+ },
38
+ "peerDependencies": {
39
+ "astro": ">=5"
40
+ }
41
+ }