mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-11 03:12:56 +00:00
## Preact Block Integration
- Enable Preact component detection for data-driven pages:
- Fix init.html to resolve sections_source + per-section ref before Preact detection
- Correct resource paths: blox/* → js/hbx/blocks/* (Hugo module mounts)
- Update libraries.html to load Preact core + compiled block scripts
- Add dynamic icon rendering for Preact components:
- Create Icon.jsx component with SVG decoding
- Add get_icon_data.html partial for passing icon strings to Preact props
- Update preact-wrapper.html to fetch icon data and inject into props
- Wire hero component to render dynamic icons via <Icon svg={icon_svg} />
- Centralized logging system:
- Add functions/logger.html to wrap warnf/errorf safely
- Degrade to HTML comments in constrained contexts (content adapters)
## Reusable Landing Page Content System
- Add sections_source support:
- Page front matter: sections_source: pages/<key> loads base from data/pages/<key>.yaml
- Inline sections deep-merge over base by position; extras appended
- Add per-section ref system:
- Any section: ref: blocks/<slug> loads from data/blocks/<slug>.yaml
- Inline section properties deep-merge over ref (content/design submaps)
- Enable content reuse across multiple landing pages
- Create reusable block library:
- Add test/data/blocks/: hero_basic.yaml, features_basic.yaml
- Add test/content/linked/index.md demo using refs with overrides
- Add pragmatic deep merge for content/design override handling
## Infrastructure & Schemas
- Update base-block.json schema:
- Fix gradient structure: flat → nested (gradient.start/end/direction)
- Fix color structure: string|{light,dark} (matches parse_block_v3.html)
- Update hero schema to properly extend base via $ref
- Fix Tailwind source path generation:
- Add tailwind_sources.html with test vs starter site logic
- scripts/view-test.sh: export HUGO_BLOX_TEST_SITE=true
- Update block directory structure:
- blox/<name>/config.html (was blox/<name>--CONFIG.html)
- Apply to init.html + parse_block_v2.html
- Code quality improvements:
- Biome config: match Prettier rules
## Content Adapters (Removed)
- Investigated Hugo content adapters for landing pages
- Found execution context limitations (early build phase, limited site methods)
- Archived to backups/content-adapters-*.zip and removed from test site
- Decision: use standard pages + data linking instead of adapters
This enables dynamic Preact rendering with proper icon support while providing a flexible, reusable content system for landing pages that maintains the "single file = page" mental model with optional advanced linking.
108 lines
2.6 KiB
JavaScript
108 lines
2.6 KiB
JavaScript
/**
|
|
* Vite Configuration for Vendoring JavaScript Libraries
|
|
*
|
|
* This config is used by Hugo Blox maintainers to copy third-party
|
|
* JavaScript libraries from node_modules into the Hugo module's assets.
|
|
*
|
|
* Usage: pnpm run vendor:libs
|
|
*/
|
|
|
|
import { resolve } from "path";
|
|
import del from "rollup-plugin-delete";
|
|
import { defineConfig } from "vite";
|
|
import { viteStaticCopy } from "vite-plugin-static-copy";
|
|
|
|
const MODULE_DIR = "modules/blox-tailwind";
|
|
const OUTPUT_DIR = resolve(MODULE_DIR, "assets/dist/lib");
|
|
|
|
export default defineConfig({
|
|
build: {
|
|
emptyOutDir: true,
|
|
outDir: OUTPUT_DIR,
|
|
lib: {
|
|
entry: resolve(MODULE_DIR, "assets/js/vendor-libs.js"),
|
|
formats: ["es"],
|
|
fileName: "vendor-libs",
|
|
},
|
|
rollupOptions: {
|
|
// Don't bundle these libraries, just copy them
|
|
external: [
|
|
"mermaid",
|
|
"plotly.js",
|
|
"katex",
|
|
"markmap-autoloader",
|
|
"alpinejs",
|
|
],
|
|
},
|
|
},
|
|
|
|
plugins: [
|
|
// Copy vendor libraries to module assets
|
|
viteStaticCopy({
|
|
targets: [
|
|
// Mermaid - Diagram rendering
|
|
{
|
|
src: "node_modules/mermaid/dist/mermaid.min.js",
|
|
dest: "mermaid/",
|
|
},
|
|
|
|
// Plotly - Interactive charts
|
|
{
|
|
src: "node_modules/plotly.js/dist/plotly.min.js",
|
|
dest: "plotly/",
|
|
},
|
|
|
|
// KaTeX - Math rendering
|
|
{
|
|
src: "node_modules/katex/dist/katex.min.js",
|
|
dest: "katex/",
|
|
},
|
|
{
|
|
src: "node_modules/katex/dist/katex.min.css",
|
|
dest: "katex/",
|
|
},
|
|
{
|
|
src: "node_modules/katex/dist/contrib/auto-render.min.js",
|
|
dest: "katex/",
|
|
},
|
|
{
|
|
src: "node_modules/katex/dist/fonts/",
|
|
dest: "katex/",
|
|
},
|
|
|
|
// Markmap - Mind map rendering
|
|
{
|
|
src: "node_modules/markmap-autoloader/dist/index.js",
|
|
dest: "markmap/",
|
|
},
|
|
// Alpine.js
|
|
{
|
|
src: "node_modules/alpinejs/dist/cdn.min.js",
|
|
dest: "alpinejs/",
|
|
},
|
|
|
|
// Preact for interactive components
|
|
{
|
|
src: "node_modules/preact/dist/preact.min.js",
|
|
dest: "preact/",
|
|
},
|
|
{
|
|
src: "node_modules/preact/dist/preact.min.js.map",
|
|
dest: "preact/",
|
|
},
|
|
{
|
|
src: "node_modules/preact/hooks/dist/hooks.umd.js",
|
|
dest: "preact/",
|
|
rename: "hooks.min.js",
|
|
},
|
|
],
|
|
}),
|
|
|
|
// Clean up any unwanted build artifacts
|
|
del({
|
|
targets: `${OUTPUT_DIR}/vendor-libs.js`, // Remove the dummy entry file
|
|
hook: "writeBundle",
|
|
}),
|
|
],
|
|
});
|