### Running domstack Examples Source: https://github.com/bcomnes/domstack/blob/next/README.md Provides instructions on how to clone the domstack repository, install dependencies, navigate to an example directory, install its specific dependencies, and start the example. ```bash git clone git@github.com:bcomnes/domstack.git cd domstack # install the top level deps npm i cd example:{example-name} # install the example deps npm i # start the example npm start ``` -------------------------------- ### Install and Build DOMStack Example Source: https://github.com/bcomnes/domstack/blob/next/examples/string-layouts/README.md Commands to install project dependencies using npm, build the site, and watch for changes during development. These are essential steps to get the example running and to facilitate development workflows. ```bash # Install dependencies npm install ``` ```bash # Build the site npm run build ``` ```bash # Watch for changes during development npm run watch ``` -------------------------------- ### Install and Build DOMStack Example Source: https://github.com/bcomnes/domstack/blob/next/examples/default-layout/README.md Commands to install project dependencies and build the DOMStack example site. This includes installing necessary packages and running build or watch commands for development. ```bash npm install ``` ```bash npm run build ``` ```bash npm run watch ``` -------------------------------- ### Install and Run DOMStack Worker Example Source: https://github.com/bcomnes/domstack/blob/next/examples/worker-example/README.md Commands to navigate to the example directory, install Node.js dependencies, and build/serve the DOMStack web worker example using npm. ```bash # Navigate to the example directory cd examples/worker-example # Install dependencies npm install # Build and serve npm start ``` -------------------------------- ### Install DOMStack CLI Source: https://github.com/bcomnes/domstack/blob/next/README.md Installs the DOMStack static site generator package using npm. This is the primary command to get started with the tool. ```bash npm install @domstack/static ``` -------------------------------- ### DOMStack Installation and Build Commands Source: https://github.com/bcomnes/domstack/blob/next/examples/basic/README.md Commands to install project dependencies, build the static site, and watch for changes during development. These are essential for setting up and running the DOMStack example. ```bash # Install dependencies npm install ``` ```bash # Build the site npm run build ``` ```bash # Watch for changes during development npm run watch ``` -------------------------------- ### Install Dependencies with npm Source: https://github.com/bcomnes/domstack/blob/next/examples/uhtml-isomorphic/README.md Installs all necessary project dependencies using the Node Package Manager (npm). This is a prerequisite for building and running the example. ```bash npm install ``` -------------------------------- ### Build and Watch Commands Source: https://github.com/bcomnes/domstack/blob/next/examples/basic/src/README.md Provides commands for installing dependencies, building the project, and enabling development watch mode. ```bash npm install npm run build ``` ```bash npm run watch ``` -------------------------------- ### Custom Container Syntax Examples (Markdown) Source: https://github.com/bcomnes/domstack/blob/next/examples/markdown-settings/README.md These Markdown examples demonstrate custom container syntax for warnings, info boxes, and collapsible sections, as configured via the markdown-it.settings.js file. ```markdown ::: warning Security Notice This is a custom warning container. ::: ``` ```markdown ::: info Did you know? This is a custom info container. ::: ``` ```markdown ::: details Click to expand This content is hidden by default. ::: ``` -------------------------------- ### Custom Code Block Example (Python) Source: https://github.com/bcomnes/domstack/blob/next/examples/markdown-settings/src/README.md An example of a Python code block rendered with custom styling applied via markdown-it settings. This demonstrates the consistent application of custom styling across different programming languages. ```python # Python code also gets the custom treatment def greet(name): return f"Hello, {name}!" ``` -------------------------------- ### Custom Code Block Example (JavaScript) Source: https://github.com/bcomnes/domstack/blob/next/examples/markdown-settings/src/README.md An example of a JavaScript code block rendered with custom styling applied via markdown-it settings. This highlights how code blocks can be enhanced for better presentation. ```javascript // This code block has a custom class const greeting = "Hello from custom markdown-it settings!"; console.log(greeting); ``` -------------------------------- ### Initialize and Use Web Workers in DOMStack Client Code Source: https://github.com/bcomnes/domstack/blob/next/examples/worker-example/README.md JavaScript code to fetch meta.json, get hashed worker paths, and initialize a web worker. Demonstrates sending a message and handling responses. ```javascript // First, fetch the meta.json to get worker paths async function initializeWorkers() { const response = await fetch('./meta.json'); const meta = await response.json(); // Initialize workers with the correct hashed filenames const counterWorker = new Worker( new URL(`./${meta.workers.counter}`, import.meta.url), { type: 'module' } ); // Use the workers counterWorker.postMessage({ action: 'increment' }); counterWorker.onmessage = (e) => { counterElement.textContent = e.data.count; }; } ``` -------------------------------- ### DOMStack Build Command Example Source: https://github.com/bcomnes/domstack/blob/next/examples/nested-dest/README.md Demonstrates the DOMStack command-line interface for building documentation. It specifies the source directory as the current directory (`.`) and includes a custom ignore pattern for a specific directory (`ignore`), while also applying default ignore patterns for common directories like `node_modules`. ```bash domstack --src . --ignore ignore ``` -------------------------------- ### Project Structure Source: https://github.com/bcomnes/domstack/blob/next/examples/css-modules/src/README.md Illustrates the directory layout for a DOMStack project utilizing CSS Modules, showing global styles, layouts, and component modules. ```text src/ ├── globals/ # Global styles and scripts ├── layouts/ # Layout templates ├── modules/ # Components with CSS modules │ ├── app.module.css # Module-scoped CSS │ ├── client.js # Client-side hydration │ ├── page.js # Server-side component │ └── style.css # Regular CSS └── README.md # This file (becomes index.html) ``` -------------------------------- ### Build and Watch Site with npm Source: https://github.com/bcomnes/domstack/blob/next/examples/uhtml-isomorphic/README.md Builds the project for deployment or watches for file changes during development. The 'build' command compiles the site, and 'watch' recompiles automatically on changes. ```bash npm run build # Watch for changes during development npm run watch ``` -------------------------------- ### Install and Build DOMStack Project Source: https://github.com/bcomnes/domstack/blob/next/examples/react/src/README.md Commands to install project dependencies and build the application. Use 'npm run watch' for continuous development monitoring. ```bash npm install npm run build ``` ```bash npm run watch ``` -------------------------------- ### Initialize DOMStack Web Worker in client.js Source: https://github.com/bcomnes/domstack/blob/next/examples/worker-example/src/README.md Demonstrates how to initialize a web worker in a DOMStack project. It fetches the `workers.json` file to get the hashed worker filename, then creates a new Worker instance using `new URL` for dynamic module loading. It also shows basic message posting and receiving. ```javascript async function initializeWorkers() { // Fetch the workers.json to get the hashed worker filenames const response = await fetch('./workers.json'); const workersData = await response.json(); // Initialize workers with the correct hashed filenames const counterWorker = new Worker( new URL(`./${workersData.counter}`, import.meta.url), { type: 'module' } ); // Send messages to the worker counterWorker.postMessage({ action: 'increment' }); // Receive messages from the worker counterWorker.onmessage = (e) => { console.log(e.data.count); }; return counterWorker; } // Initialize workers when the page loads const counterWorker = await initializeWorkers(); ``` -------------------------------- ### DOMStack Worker Example Project Structure Source: https://github.com/bcomnes/domstack/blob/next/examples/worker-example/README.md Illustrates the directory layout for a DOMStack project featuring web workers, including worker files, client-side code, and page templates. ```plaintext worker-example/ ├── package.json # Project dependencies and scripts ├── src/ │ ├── globals/ # Global styles and variables │ ├── layouts/ # Page layouts │ ├── README.md # Home page content │ └── worker-page/ # Web worker example page │ ├── page.js # Main page template │ ├── client.js # Client-side code for worker interaction │ ├── counter.worker.js # Counter worker implementation │ ├── fibonacci.worker.js # Fibonacci calculator worker │ └── style.css # Page-specific styles ``` -------------------------------- ### domstack Project Structure Example Source: https://github.com/bcomnes/domstack/blob/next/README.md Illustrates the typical directory structure for a domstack project, showing how pages, layouts, global assets, and workers are organized. The src directory structure directly maps to the website's routing. ```bash src/ ├── md-page │ ├── README.md │ ├── client.ts │ ├── style.css │ ├── loose-md-page.md │ └── nested-page │ ├── README.md │ ├── style.css │ └── client.js ├── html-page │ ├── client.tsx │ ├── page.html │ ├── page.vars.ts │ └── style.css ├── js-page │ └── page.js ├── ts-page │ ├── client.ts │ ├── page.vars.ts │ └── page.ts ├── feeds │ └── feeds.template.ts ├── page-with-workers │ ├── client.ts │ ├── page.ts │ ├── counter.worker.ts │ └── analytics.worker.js ├── layouts │ ├── blog.layout.ts │ ├── blog.layout.css │ ├── blog.layout.client.ts │ ├── article.layout.ts │ ├── javascript.layout.js │ └── root.layout.ts ├── globals │ ├── global.client.ts │ ├── global.css │ ├── global.vars.ts │ ├── markdown-it.settings.ts │ └── esbuild.settings.ts ├── README.md ├── client.ts ├── style.css └── favicon-16x16.png ``` -------------------------------- ### Local Release Commands Source: https://github.com/bcomnes/domstack/blob/next/CONTRIBUTING.md Steps to perform a local release if the automated system is not used. This involves updating the version number, generating a changelog, and publishing to npm. ```bash npm version patch npm publish ``` -------------------------------- ### JavaScript Configuration Function Source: https://github.com/bcomnes/domstack/blob/next/examples/markdown-settings/src/README.md Demonstrates the structure of the `markdown-it.settings.js` file. This file exports an asynchronous function that receives the default markdown-it instance and returns a modified version, allowing for plugin additions and customizations. ```javascript export default async function markdownItSettingsOverride (md) { // Add plugins and customizations here return md } ``` -------------------------------- ### Markdown Page Layout Reference Source: https://github.com/bcomnes/domstack/blob/next/README.md An example of a Markdown page frontmatter, demonstrating how to specify a custom layout for rendering the page. ```markdown --- layout: 'article' title: 'My Article Title' --- Thanks for reading my article ``` -------------------------------- ### JavaScript Console Log Example Source: https://github.com/bcomnes/domstack/blob/next/test-cases/general-features/src/md-page/markdown-settings-test.md Demonstrates a basic JavaScript console log statement. This snippet is useful for verifying JavaScript execution environments and basic output. ```javascript // Code blocks should work console.log('Hello, world!'); ``` -------------------------------- ### Web Worker Directory Structure Example Source: https://github.com/bcomnes/domstack/blob/next/README.md Illustrates the typical file organization for web workers within a DOMStack project, showing page files and their corresponding worker files. ```bash page-directory/ ├── page.js ├── client.js ├── counter.worker.js # Worker with counter functionality └── data.worker.js # Worker for data processing ``` -------------------------------- ### NPM Publish Command Source: https://github.com/bcomnes/domstack/blob/next/CONTRIBUTING.md Publishes the current version of the package to the npm registry. This command also pushes local git branches and tags to the default remote and creates a GitHub release. ```APIDOC NPM Publish Command: npm publish Description: Publishes the package to the npm registry. It also pushes local git branches and tags to the default remote, and performs a GitHub release. Prerequisites: - A clean working git workspace. - The version number must be updated via `npm version`. Returns: - Publishes the package to npm. - Pushes git branches and tags. - Creates a GitHub release. ``` -------------------------------- ### PostVars Example: Generating Blog Post List Source: https://github.com/bcomnes/domstack/blob/next/README.md An example of a `postVars` function in TypeScript that introspects site pages to find blog posts, sorts them by publish date, and renders an HTML list of the latest five posts. This generated HTML is then returned to be merged into the page's variables. ```typescript import { html } from 'htm/preact' import { render } from 'preact-render-to-string' import type { PostVarsFunction } from '@domstack/static' export const postVars: PostVarsFunction = async ({ pages }) => { const blogPosts = pages .filter(page => page.vars.layout === 'article') .sort((a, b) => new Date(b.vars.publishDate) - new Date(a.vars.publishDate)) .slice(0, 5) const blogpostsHtml = render(html`
Welcome to uhtml-isomorphic