diff --git a/examples/cargo-like/src/fonts/SOURCES.txt b/examples/cargo-like/src/fonts/SOURCES.txt index 95ea8e6b..40229b36 100644 --- a/examples/cargo-like/src/fonts/SOURCES.txt +++ b/examples/cargo-like/src/fonts/SOURCES.txt @@ -16,10 +16,10 @@ Local license: Fraunces-OFL.txt Project: https://github.com/undercasetype/Fraunces DS Weiss-Gotisch (regular, unmodified TrueType) -Copied from the local DOMStack source: fonts/ds-weiss-gotisch/DSWeiss-Gotisch.ttf -Accompanying license copied from: fonts/ds-weiss-gotisch/1001fonts-ds-weiss-gotisch-eula.txt +Copied from the local DOMStack source: site/fonts/ds-weiss-gotisch/DSWeiss-Gotisch.ttf +Accompanying license copied from: site/fonts/ds-weiss-gotisch/1001fonts-ds-weiss-gotisch-eula.txt Local license: DSWeiss-Gotisch-LICENSE.txt -Upstream directory: https://github.com/bcomnes/domstack/tree/master/fonts/ds-weiss-gotisch +Upstream directory: https://github.com/bcomnes/domstack/tree/master/site/fonts/ds-weiss-gotisch License: 1001Fonts Free For Commercial Use License (FFC). Free personal/commercial use, but modification and publication/distribution have separate restrictions. Review the license before publishing the font files. diff --git a/package.json b/package.json index ea751f4a..c14ffdf9 100644 --- a/package.json +++ b/package.json @@ -137,10 +137,10 @@ "clean-node_modules": "rm -rf node_modules && rm -rf examples/*/node_modules", "build": "npm run clean && npm run build:defaults && run-p build:domstack build:declaration build:schema", "build:defaults": "node scripts/build-defaults.js", - "build:domstack": "./bin.js --src . --ignore examples,/eject-deps,test-cases,test-fixtures,type-tests,coverage,*.tsconfig.json,fonts,/lib,/types,/scripts,/plans,/browser-tests,/test-results,/lcov.info,/tsconfig.json,/AGENTS.md,/AGENT.md,/agents.md", - "new-blogpost": "node tools/blog/create.ts", - "publish-draft": "node tools/blog/publish.ts", - "import-author": "node tools/authors/import.ts", + "build:domstack": "./bin.js --src . --ignore examples,/eject-deps,test-cases,test-fixtures,type-tests,coverage,*.tsconfig.json,/site/fonts,/site/tools,/lib,/types,/scripts,/plans,/browser-tests,/test-results,/lcov.info,/tsconfig.json,/AGENTS.md,/AGENT.md,/agents.md", + "new-blogpost": "node site/tools/blog/create.ts", + "publish-draft": "node site/tools/blog/publish.ts", + "import-author": "node site/tools/authors/import.ts", "build:declaration": "node ./node_modules/typescript7/bin/tsc -p declaration.tsconfig.json", "build:schema": "node scripts/domstack-manifest-schema.js", "watch": "npm run clean && run-p watch:*", diff --git a/authors/bcomnes/author-meta.json b/site/authors/bcomnes/author-meta.json similarity index 100% rename from authors/bcomnes/author-meta.json rename to site/authors/bcomnes/author-meta.json diff --git a/authors/bcomnes/avatar.jpg b/site/authors/bcomnes/avatar.jpg similarity index 100% rename from authors/bcomnes/avatar.jpg rename to site/authors/bcomnes/avatar.jpg diff --git a/fonts/ds-weiss-gotisch/1001fonts-ds-weiss-gotisch-eula.txt b/site/fonts/ds-weiss-gotisch/1001fonts-ds-weiss-gotisch-eula.txt similarity index 100% rename from fonts/ds-weiss-gotisch/1001fonts-ds-weiss-gotisch-eula.txt rename to site/fonts/ds-weiss-gotisch/1001fonts-ds-weiss-gotisch-eula.txt diff --git a/fonts/ds-weiss-gotisch/DSWeiss-Gotisch.ttf b/site/fonts/ds-weiss-gotisch/DSWeiss-Gotisch.ttf similarity index 100% rename from fonts/ds-weiss-gotisch/DSWeiss-Gotisch.ttf rename to site/fonts/ds-weiss-gotisch/DSWeiss-Gotisch.ttf diff --git a/fonts/ds-weiss-gotisch/DSWeiss-GotischAlt.ttf b/site/fonts/ds-weiss-gotisch/DSWeiss-GotischAlt.ttf similarity index 100% rename from fonts/ds-weiss-gotisch/DSWeiss-GotischAlt.ttf rename to site/fonts/ds-weiss-gotisch/DSWeiss-GotischAlt.ttf diff --git a/site/globals/global.css b/site/globals/global.css index 9caecd4c..a5bec7dd 100644 --- a/site/globals/global.css +++ b/site/globals/global.css @@ -9,7 +9,7 @@ @font-face { font-family: 'DSWeiss-Gotisch'; - src: url('../../fonts/ds-weiss-gotisch/DSWeiss-Gotisch.ttf') format('truetype'); + src: url('../fonts/ds-weiss-gotisch/DSWeiss-Gotisch.ttf') format('truetype'); } body { diff --git a/site/lib/authors.ts b/site/lib/authors.ts index e290311c..f6e38fb4 100644 --- a/site/lib/authors.ts +++ b/site/lib/authors.ts @@ -20,7 +20,7 @@ export interface AuthorMeta { gpg: string } -export const authorRegistryDirectory = join(import.meta.dirname, '../../authors') +export const authorRegistryDirectory = join(import.meta.dirname, '../authors') export function validateAuthorUsername (value: unknown): string { if (typeof value !== 'string' || !/^[a-z0-9](?:[a-z0-9-]{0,37}[a-z0-9])?$/.test(value) || value.includes('--')) { @@ -114,7 +114,7 @@ export class AuthorRegistry { const meta = validateAuthorMeta(JSON.parse(await readFile(metaPath, 'utf8')), username) const avatar = await lstat(join(directory, meta.avatar)) if (!avatar.isFile() || avatar.isSymbolicLink() || !avatar.size) throw new Error('avatar must be a nonempty regular file') - return Object.freeze({ username, name: meta.name, url: meta.website || meta.profile, avatar: `/authors/${username}/${meta.avatar}` }) + return Object.freeze({ username, name: meta.name, url: meta.website || meta.profile, avatar: `/site/authors/${username}/${meta.avatar}` }) } catch (error) { throw new Error(`${metaPath}: ${error instanceof Error ? error.message : String(error)}`) } diff --git a/site/lib/blog.test.js b/site/lib/blog.test.js index 6436cbf5..afd61665 100644 --- a/site/lib/blog.test.js +++ b/site/lib/blog.test.js @@ -24,7 +24,7 @@ const post = { test('blog metadata validates RFC 3339 dates and author arrays', async () => { assert.equal(blogDate('2024-02-29T12:00:00Z', 'publishDate', 'sample'), '2024-02-29T12:00:00.000Z') - assert.deepEqual(await resolveBlogAuthors(['bcomnes'], 'sample'), [{ username: 'bcomnes', name: 'Bret Comnes', url: 'https://bret.io/', avatar: '/authors/bcomnes/avatar.jpg' }]) + assert.deepEqual(await resolveBlogAuthors(['bcomnes'], 'sample'), [{ username: 'bcomnes', name: 'Bret Comnes', url: 'https://bret.io/', avatar: '/site/authors/bcomnes/avatar.jpg' }]) await assert.rejects(validateBlogVars({ description: 'Summary', publishDate: '2026-01-02T00:00:00Z', authors: ['bcomnes'] }, 'sample'), /sample: title/) await assert.rejects(validateBlogVars({ title: 'Title', description: 'Summary', publishDate: '2026-01-02T00:00:00Z', authors: [] }, 'sample'), /nonempty array/) await assert.rejects(validateBlogVars({ title: 'Title', description: 'Summary', publishDate: '2026-01-02T00:00:00Z', authors: ['bcomnes', 'bcomnes'] }, 'sample'), /duplicate/) @@ -74,7 +74,7 @@ test('feeds include ordered author metadata, avatars, and absolute article asset assert.equal($('a').attr('href'), `${site}/blog/2026/other/`) assert.equal($('img').attr('src'), `${site}/blog/2026/example/image.png`) const json = JSON.parse(jsonFeed([post], site)) - assert.deepEqual(json.items[0].authors, [{ name: 'Bret Comnes', url: 'https://bret.io/', avatar: `${site}/authors/bcomnes/avatar.jpg` }]) + assert.deepEqual(json.items[0].authors, [{ name: 'Bret Comnes', url: 'https://bret.io/', avatar: `${site}/site/authors/bcomnes/avatar.jpg` }]) assert.equal(json.items[0].content_html, feedHtml(post, site)) assert.match(atomFeed([post], site), /\s+Bret Comnes<\/name>\s+https:\/\/bret\.io\/<\/uri>\s+<\/author>/) }) diff --git a/tools/authors/README.md b/site/tools/authors/README.md similarity index 88% rename from tools/authors/README.md rename to site/tools/authors/README.md index 6e1aecb1..a4362d04 100644 --- a/tools/authors/README.md +++ b/site/tools/authors/README.md @@ -4,7 +4,7 @@ Import or refresh a public GitHub profile: ```sh npm run import-author -- bcomnes -node --test tools/authors/import.test.js +node --test site/tools/authors/import.test.js ``` Importing makes bounded HTTPS requests to `api.github.com` for the profile and social accounts, `avatars.githubusercontent.com` for the avatar, and `github.com` for public SSH/GPG keys. GitHub rate limits apply. An optional `GITHUB_TOKEN` environment variable is sent only to `api.github.com` and is never written to metadata. @@ -13,7 +13,7 @@ Redirects are rejected, no token is needed for public profiles, and network fail ## Files and schema -Each `authors//` directory contains `author-meta.json` and `avatar.jpg`, `avatar.png`, `avatar.gif`, or `avatar.webp`. +Each `site/authors//` directory contains `author-meta.json` and `avatar.jpg`, `avatar.png`, `avatar.gif`, or `avatar.webp`. Metadata schema version 1 contains: @@ -35,7 +35,7 @@ Only public data is stored. These files are intended to be checked in; do not ad `AuthorRegistry` lazily reads one username at a time, shares in-flight and successful reads, evicts failed reads for retry, returns frozen author objects, and supports `clear(username?)`. `resolveBlogAuthors` requires a nonempty array of unique registered GitHub usernames and preserves input order. It has no default and rejects legacy aliases such as `bret`, `joe`, and `oro`. -Resolved author URLs prefer the imported website and fall back to the GitHub profile. Avatar URLs are local `/authors//` paths so builds do not contact GitHub. +Resolved author URLs prefer the imported website and fall back to the GitHub profile. Avatar URLs are local `/site/authors//` paths so builds do not contact GitHub. The registry reads metadata through `fs`, so DOMStack does not automatically invalidate pages when registry files change. Restart the watch process after importing authors or manually editing metadata, or run a fresh build. diff --git a/tools/authors/import.test.js b/site/tools/authors/import.test.js similarity index 97% rename from tools/authors/import.test.js rename to site/tools/authors/import.test.js index 288b3f12..3ce4e838 100644 --- a/tools/authors/import.test.js +++ b/site/tools/authors/import.test.js @@ -4,7 +4,7 @@ import { tmpdir } from 'node:os' import { join } from 'node:path' import test from 'node:test' import { importAuthor } from './import.ts' -import { AuthorRegistry, resolveBlogAuthors, validateAuthorMeta, validateAuthorUrl, validateAuthorUsername } from '../../site/lib/authors.ts' +import { AuthorRegistry, resolveBlogAuthors, validateAuthorMeta, validateAuthorUrl, validateAuthorUsername } from '../../lib/authors.ts' const png = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10, 0]) function fakeFetch (options = {}) { @@ -29,7 +29,7 @@ test('imports, loads, and preserves previous data on failed refresh', async () = assert.equal(meta.website, 'https://example.org/') assert.equal(meta.keys, '') assert.equal(meta.gpg, '') - assert.deepEqual(await new AuthorRegistry(directory).get('alice'), { username: 'alice', name: 'Alice Example', url: 'https://example.org/', avatar: '/authors/alice/avatar.png' }) + assert.deepEqual(await new AuthorRegistry(directory).get('alice'), { username: 'alice', name: 'Alice Example', url: 'https://example.org/', avatar: '/site/authors/alice/avatar.png' }) const before = await readFile(join(directory, 'alice', 'author-meta.json'), 'utf8') for (const fail of ['/users/alice', 'avatars.githubusercontent.com', '.keys', '.gpg']) { diff --git a/tools/authors/import.ts b/site/tools/authors/import.ts similarity index 98% rename from tools/authors/import.ts rename to site/tools/authors/import.ts index e64a81f0..11b6e985 100644 --- a/tools/authors/import.ts +++ b/site/tools/authors/import.ts @@ -1,8 +1,8 @@ import { mkdir, mkdtemp, lstat, rename, rm, writeFile } from 'node:fs/promises' import { join, resolve } from 'node:path' import { pathToFileURL } from 'node:url' -import { authorRegistryDirectory, validateAuthorMeta, validateAuthorUrl, validateAuthorUsername } from '../../site/lib/authors.ts' -import type { AuthorMeta } from '../../site/lib/authors.ts' +import { authorRegistryDirectory, validateAuthorMeta, validateAuthorUrl, validateAuthorUsername } from '../../lib/authors.ts' +import type { AuthorMeta } from '../../lib/authors.ts' type Request = typeof fetch diff --git a/tools/blog/create.ts b/site/tools/blog/create.ts similarity index 97% rename from tools/blog/create.ts rename to site/tools/blog/create.ts index f6b3f938..f0228d29 100644 --- a/tools/blog/create.ts +++ b/site/tools/blog/create.ts @@ -1,7 +1,7 @@ import { mkdir, writeFile } from 'node:fs/promises' import { join } from 'node:path' import { parseArgs } from 'node:util' -import { resolveBlogAuthors } from '../../site/lib/authors.ts' +import { resolveBlogAuthors } from '../../lib/authors.ts' import { context, directory, postParts, reportError, requireAbsent, type BlogOptions } from './shared.ts' export interface CreatePostOptions extends BlogOptions { authors?: string[] } diff --git a/tools/blog/publish.ts b/site/tools/blog/publish.ts similarity index 100% rename from tools/blog/publish.ts rename to site/tools/blog/publish.ts diff --git a/tools/blog/shared.ts b/site/tools/blog/shared.ts similarity index 95% rename from tools/blog/shared.ts rename to site/tools/blog/shared.ts index c2d291aa..70435fb2 100644 --- a/tools/blog/shared.ts +++ b/site/tools/blog/shared.ts @@ -7,7 +7,7 @@ export interface BlogOptions { now?: Date } -export const BLOG_DIR = fileURLToPath(new URL('../../blog/', import.meta.url)) +export const BLOG_DIR = fileURLToPath(new URL('../../../blog/', import.meta.url)) export function context (options: BlogOptions) { const now = options.now ?? new Date() diff --git a/tsconfig.json b/tsconfig.json index 5f1efac6..a19cd1f0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,6 +23,7 @@ ], "exclude": [ "node_modules", + "site/tools/**/*", "test-cases/build-errors", "test-cases/page-build-errors", "test-cases/**/public"