diff --git a/Readme.md b/Readme.md index 40f646b..11660c2 100644 --- a/Readme.md +++ b/Readme.md @@ -1,15 +1,3 @@ # hornwitser.no The code behind hornwitser.no - -## Development - -For regular development run: -- `pnpm watch-ts` to transpile the TypeScript code to build/node and watch for changes. -- `pnpm watch-site` to host the site on http://localhost:8080 and reload the server on changes. -- `pnpm test` to run the tests and report coverage. - -Other scripts available are: -- `pnpm prepare` to transpile the TypeScript code to build/node -- `pnpm build` to build the static resources to build/web. -- `pnpm serve` to host the website on http://localhost:8080 diff --git a/package.json b/package.json index 427faba..fe91023 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,7 @@ "main": "build/node/index.js", "scripts": { "prepare": "tsc", - "watch-ts": "tsc --watch", - "watch-site": "node --enable-source-maps build/node/cli.js watch", "build": "node --enable-source-maps build/node/cli.js build", - "serve": "node --enable-source-maps build/node/cli.js serve", "test": "node --test --enable-source-maps --experimental-test-coverage" }, "dependencies": { diff --git a/src/components/BasePage.tsx b/src/components/BasePage.tsx index 8e2ec7f..13674d9 100644 --- a/src/components/BasePage.tsx +++ b/src/components/BasePage.tsx @@ -18,9 +18,8 @@ source.addEventListener("reload", () => location.reload());`; {props.title} - - - , "/subdir"); - assert.equal((el as Element).attributes.get("src"), "../assets/script.js"); - }); - - test("img src", () => { - const el = resolveRefs(, "/subdir"); - assert.equal((el as Element).attributes.get("src"), "../assets/image.png"); - }); - test("nested element", () => { const el = resolveRefs(
Content with Link
, "/"); assert.equal((el.childNodes[1] as Element).attributes.get("href"), "page.html"); diff --git a/src/utils/resolve-refs.ts b/src/utils/resolve-refs.ts index 2c19dd0..7bdba49 100644 --- a/src/utils/resolve-refs.ts +++ b/src/utils/resolve-refs.ts @@ -8,13 +8,6 @@ function shallowCopyElement(element: Element) { return copy; } -const resolvedAttributes = new Map([ - ["a", "href"], - ["img", "src"], - ["link", "href"], - ["script", "src"], -]); - /** Resolves absolute href attributes in a and link elements the Node tree into relative references from the given directory. @@ -28,18 +21,20 @@ export function resolveRefs(node: Node, dir: string) { } let resolvedNode = node; const name = node.name; - let attribute = resolvedAttributes.get(name); - if (attribute && node.attributes.has(attribute)) { - const original = node.attributes.get(attribute)! + if ( + (name === "link" || name === "a") + && node.attributes.has("href") + ) { + const original = node.attributes.get("href")! if (/^[a-z][a-z+.-]*:/i.test(original)) { // Ignore refs that start with a URI scheme. /* node:coverage ignore next 3 */ } else if (!original.startsWith("/")) { - console.log(`Warning: found relative ${attribute} to ${original}`); + console.log(`Warning: found relative href to ${original}`); } else { const ref = posix.relative(dir, original); resolvedNode = shallowCopyElement(node); - resolvedNode.attributes.set(attribute, ref); + resolvedNode.attributes.set("href", ref); } } const resolvedChildren: Node[] = []; diff --git a/web/assets/fonts/ComicNeue-Bold.woff2 b/web/assets/fonts/ComicNeue-Bold.woff2 deleted file mode 100644 index 250a33f..0000000 Binary files a/web/assets/fonts/ComicNeue-Bold.woff2 and /dev/null differ diff --git a/web/assets/fonts/ComicNeue-BoldItalic.woff2 b/web/assets/fonts/ComicNeue-BoldItalic.woff2 deleted file mode 100644 index 2fecd41..0000000 Binary files a/web/assets/fonts/ComicNeue-BoldItalic.woff2 and /dev/null differ diff --git a/web/assets/fonts/ComicNeue-Italic.woff2 b/web/assets/fonts/ComicNeue-Italic.woff2 deleted file mode 100644 index f2bcb15..0000000 Binary files a/web/assets/fonts/ComicNeue-Italic.woff2 and /dev/null differ diff --git a/web/assets/fonts/ComicNeue-Light.woff2 b/web/assets/fonts/ComicNeue-Light.woff2 deleted file mode 100644 index 4f1f4f4..0000000 Binary files a/web/assets/fonts/ComicNeue-Light.woff2 and /dev/null differ diff --git a/web/assets/fonts/ComicNeue-LightItalic.woff2 b/web/assets/fonts/ComicNeue-LightItalic.woff2 deleted file mode 100644 index 3d9db1c..0000000 Binary files a/web/assets/fonts/ComicNeue-LightItalic.woff2 and /dev/null differ diff --git a/web/assets/fonts/ComicNeue-Regular.woff2 b/web/assets/fonts/ComicNeue-Regular.woff2 deleted file mode 100644 index 0580549..0000000 Binary files a/web/assets/fonts/ComicNeue-Regular.woff2 and /dev/null differ diff --git a/web/assets/styles/font.css b/web/assets/styles/font.css deleted file mode 100644 index 56ba778..0000000 --- a/web/assets/styles/font.css +++ /dev/null @@ -1,71 +0,0 @@ -@font-face { - font-family: 'Comic Neue'; - src: - local('Comic Neue Light'), - local('ComicNeue-Light'), - url('/assets/fonts/ComicNeue-Light.woff2') format('woff2') - ; - font-weight: 300; - font-style: normal; - font-display: swap; -} - -@font-face { - font-family: 'Comic Neue'; - src: - local('Comic Neue Italic'), - local('ComicNeue-Italic'), - url('/assets/fonts/ComicNeue-Italic.woff2') format('woff2') - ; - font-weight: normal; - font-style: italic; - font-display: swap; -} - -@font-face { - font-family: 'Comic Neue'; - src: - local('Comic Neue Bold'), - local('ComicNeue-Bold'), - url('/assets/fonts/ComicNeue-Bold.woff2') format('woff2') - ; - font-weight: bold; - font-style: normal; - font-display: swap; -} - -@font-face { - font-family: 'Comic Neue'; - src: - local('Comic Neue Bold Italic'), - local('ComicNeue-BoldItalic'), - url('/assets/fonts/ComicNeue-BoldItalic.woff2') format('woff2') - ; - font-weight: bold; - font-style: italic; - font-display: swap; -} - -@font-face { - font-family: 'Comic Neue'; - src: - local('Comic Neue Light Italic'), - local('ComicNeue-LightItalic'), - url('/assets/fonts/ComicNeue-LightItalic.woff2') format('woff2') - ; - font-weight: 300; - font-style: italic; - font-display: swap; -} - -@font-face { - font-family: 'Comic Neue'; - src: - local('Comic Neue Regular'), - local('ComicNeue-Regular'), - url('/assets/fonts/ComicNeue-Regular.woff2') format('woff2') - ; - font-weight: normal; - font-style: normal; - font-display: swap; -} diff --git a/web/assets/styles/base.css b/web/style.css similarity index 71% rename from web/assets/styles/base.css rename to web/style.css index fc9ea79..47b3f38 100644 --- a/web/assets/styles/base.css +++ b/web/style.css @@ -14,10 +14,6 @@ html { text-size-adjust: none; } -:is(ul, ol)[role="list"] { - list-style: none; -} - h1, h2, h3, h4, button, input, label { line-height: 1.1; } @@ -43,43 +39,29 @@ textarea:not([rows]) { /* Overall styling */ html { color-scheme: light dark; - font-family: "Comic Neue", sans-serif; + font-family: sans-serif; overflow-wrap: break-word; scrollbar-gutter: stable; } -hgroup :is(h1, h2, h3, h4) { - margin-block-start: 0; - margin-block-end: 0.1em; +hgroup h1 { + margin-bottom: 0.1em; } hgroup p { font-style: italic; + margin-bottom: 1em; } h1, h2, h3, h4 { - font-family: "Comic Neue", sans-serif; margin-block-start: 1.25em; margin-block-end: 0.5em; } -:is(hgroup, p, blockquote, ol, ul, li) + :is(hgroup, blockquote, p, ol, ul, li) { - margin-block-start: var(--block-space, 1em); -} -.tight { - --block-space: 0.35em; +:is(p, ol, ul) + :is(p, ol, ul) { + padding-block-start: 1em; } -blockquote { - padding-inline: 1.25em; -} -blockquote::before { - content: "“"; -} -blockquote::after { - content: "”"; -} - -:is(ol, ul):not([role]) { +ol, ul { padding-inline-start: 1.25em; } @@ -98,8 +80,8 @@ blockquote::after { /* Base Page Layout */ body { max-width: 50rem; - padding-inline: 0.5em; - padding-block-end: 2em; + padding: 0; + margin-block: 0; margin-inline: auto; } @@ -112,7 +94,7 @@ body { background-color: grey; } -/* about */ +/* index */ .author { display: grid; grid-template-columns: auto 1fr; @@ -120,24 +102,13 @@ body { gap: 1em; margin-block: 1em; } +.author h1 { + margin-block-start: 0; +} .author p { margin-block-end: 0; } -/* links */ -.no-break { - display: inline-block; - max-width: 100%; -} -.link { - background-color: color-mix(in oklab, Canvas 90%, white); - padding: 0.5em; - border-radius: 0.5em; -} -.link>* { - --block-space: 0.5em; -} - /* sandbox */ .sandbox-inset-3d { contain: paint; diff --git a/web/assets/scripts/viewport.js b/web/viewport.js similarity index 100% rename from web/assets/scripts/viewport.js rename to web/viewport.js