From 2ef2f5d97448367c552a7a4029db68e7d7c5dedc Mon Sep 17 00:00:00 2001 From: wholteza Date: Sat, 4 Oct 2025 16:08:11 +0200 Subject: [PATCH] Add playground --- packages/@zblog/toolchain/src/file-loader.ts | 13 +- src/assets/base.css | 53 ++++++++ src/index.ts | 9 +- src/playground/playground.html | 130 +++++++++++++++++++ src/templates/404.html | 27 ++-- src/templates/index.html | 43 +----- src/templates/note.html | 41 +----- 7 files changed, 216 insertions(+), 100 deletions(-) create mode 100644 src/assets/base.css create mode 100644 src/playground/playground.html diff --git a/packages/@zblog/toolchain/src/file-loader.ts b/packages/@zblog/toolchain/src/file-loader.ts index 640b273..9b3f019 100644 --- a/packages/@zblog/toolchain/src/file-loader.ts +++ b/packages/@zblog/toolchain/src/file-loader.ts @@ -19,23 +19,24 @@ export class FileLoader implements IPluginBuilder { const { menuManifest } = builderContext; const { files } = this.options; files.forEach((file) => { - const fileName = - file.nameOverride ?? file.path.split("/").pop() ?? file.path; + const filePath = file.path.split("/").pop() ?? file.path; + const fileName = file.nameOverride ?? filePath; const isImage = fileName.match(/\.(png|jpe?g|gif|webp)$/); if (isImage) { console.log("Processing image", file.path); ffmpeg(file.path) - .output(`${builderContext.outputDirectory}/${fileName}`) + .output(`${builderContext.outputDirectory}/${filePath}`) .size(`${this.options.imageWidth ?? 200}x?`) .run(); } else { - console.log("Copying file", file.path); - copyFile(file.path, `${builderContext.outputDirectory}/${fileName}`); + const destination = `${builderContext.outputDirectory}/${filePath}`; + console.log("Copying file", file.path, "to", destination); + copyFile(file.path, destination); } if (file.menuEntry) { menuManifest.push({ name: fileName, - link: file.path, + link: filePath, }); } }); diff --git a/src/assets/base.css b/src/assets/base.css new file mode 100644 index 0000000..a6e6280 --- /dev/null +++ b/src/assets/base.css @@ -0,0 +1,53 @@ +:root { + --color-background: #1c1b28; + --color-accent: #00FFFF; + --color-text: #FFF; + + --content-width: 800px; + + --font-size-base: 18px; + --line-height-base: 26px; + --font-family: monospace; + + --space-base: 1rem; +} + +.banner { + margin-top: 1rem; + width: 100%; + height: 40px; + display: flex; + flex-direction: row; + margin-bottom: 1rem; + align-items: center; + flex: 1; + font-family: monospace; +} + +.banner { + .title { + display: flex; + flex-direction: row; + flex: 1; + + .name { + color: #1c1b28; + background-color: #00FFFF; + white-space: nowrap; + padding: 5px; + + a { + color: unset; + text-decoration: none; + } + } + } + + .title::after { + background: repeating-linear-gradient(90deg, #00FFFF, #00FFFF 2px, transparent 0, transparent 10px); + content: ""; + display: block; + width: 100%; + margin-left: 10px; + } +} diff --git a/src/index.ts b/src/index.ts index 8f10ac9..23ccf86 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,7 +24,6 @@ new ToolchainBuilder(paths) files: [ { path: "src/templates/404.html", - nameOverride: "Not Found Page", menuEntry: false, }, { @@ -32,6 +31,14 @@ new ToolchainBuilder(paths) }, { path: "src/assets/favicon.ico", + }, + { + path: "src/assets/base.css" + }, + { + path: "src/playground/playground.html", + menuEntry: true, + nameOverride: "CSS/HTML playground" } ], }), diff --git a/src/playground/playground.html b/src/playground/playground.html new file mode 100644 index 0000000..a7b96d4 --- /dev/null +++ b/src/playground/playground.html @@ -0,0 +1,130 @@ + + + + + + + + + + + +

This is an interactive html and css playground built with minimal JS.

+
+ + + + + diff --git a/src/templates/404.html b/src/templates/404.html index 9857560..dce71aa 100644 --- a/src/templates/404.html +++ b/src/templates/404.html @@ -1,15 +1,18 @@ - - - - Page Not Found - - -
-

404

-

Page Not Found

-

The specified file was not found on this website. Please check the URL for mistakes and try again.

-
- + + + + + Page Not Found + + + +
+

404

+

Page Not Found

+

The specified file was not found on this website. Please check the URL for mistakes and try again.

+
+ + diff --git a/src/templates/index.html b/src/templates/index.html index 23ecd71..c9d98d4 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -5,6 +5,7 @@ Document + diff --git a/src/templates/note.html b/src/templates/note.html index 0003d97..e71e1ea 100644 --- a/src/templates/note.html +++ b/src/templates/note.html @@ -5,6 +5,7 @@ Document +