Files
HugoBlox-kit/scripts/view-starter-dev.sh
T
George Cushen a2aaa838c0 feat(preact+landing): enable Preact block rendering + reusable landing page content system
## 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.
2025-09-22 22:18:03 +01:00

122 lines
3.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
INITIAL_DIR="$(pwd)"
cleanup() {
cd "$INITIAL_DIR" || true
}
trap cleanup EXIT INT TERM
usage() {
echo "View a starter template with local development modules and debug features."
echo ""
echo "Usage: ./scripts/view-starter-dev.sh [<starter-name>] [--debug] [--no-pagefind]"
echo "Example: ./scripts/view-starter-dev.sh blog --debug"
echo "Default starter: academic-cv (if no starter-name provided)"
echo ""
echo "This script uses:"
echo " • Local development modules (via HUGO_MODULE_REPLACEMENTS)"
echo " • Development environment with demo/debug flags enabled"
echo " • Optional Pagefind search indexing and enhanced debugging"
}
STARTER="academic-cv" # Default starter if none provided
DEBUG_MODE=false
PAGEFIND=true
while [ $# -gt 0 ]; do
case "$1" in
--debug)
DEBUG_MODE=true
shift
;;
--no-pagefind)
PAGEFIND=false
shift
;;
-h|--help)
usage
exit 0
;;
-*)
echo "Unknown option: $1"
usage
exit 1
;;
*)
STARTER="$1"
shift
;;
esac
done
# Run Hugo from the site dir so Tailwind CLI is discoverable
cd "starters/$STARTER"
# Ensure Tailwind CLI exists in starter (required for Hugo css.TailwindCSS)
if [ -f "package.json" ] && [ ! -x "node_modules/.bin/tailwindcss" ]; then
echo "📦 Installing Tailwind CLI in starter directory for Hugo..."
if command -v pnpm >/dev/null 2>&1; then
pnpm install
else
npm install
fi
fi
# Core environment for local dev linking modules and enabling demo/debug flags
export HUGO_BLOX_DEMO=true
export HUGO_BLOX_DEBUG=true
export HUGO_ENVIRONMENT=development
export HUGO_BLOX_MONOREPO=true
export HUGOxPARAMSxDECAP_CMSxLOCAL_BACKEND=true
# Link local modules for development (Hugo module replacements)
export HUGO_MODULE_REPLACEMENTS="\
github.com/HugoBlox/hugo-blox-builder/modules/blox-tailwind -> ../../../modules/blox-tailwind,\
github.com/HugoBlox/hugo-blox-builder/modules/blox-analytics -> ../../../modules/blox-analytics,\
github.com/HugoBlox/hugo-blox-builder/modules/blox-plugin-netlify -> ../../../modules/blox-plugin-netlify,\
github.com/HugoBlox/hugo-blox-builder/modules/blox-plugin-reveal -> ../../../modules/blox-plugin-reveal,\
github.com/HugoBlox/hugo-blox-builder/modules/blox-plugin-decap-cms -> ../../../modules/blox-plugin-decap-cms\
"
# Optionally pre-build and generate Pagefind index for local search
if [ "$PAGEFIND" = true ]; then
hugo
if command -v pnpm >/dev/null 2>&1; then
pnpm dlx pagefind --site "public" --output-subdir ../static/pagefind
else
npm_config_yes=true npx pagefind --site "public" --output-subdir ../static/pagefind
fi
fi
# Compose Hugo server args
HUGO_ARGS=(
server
--disableFastRender
--printI18nWarnings
--printPathWarnings
--gc
-F
--port 8081
--bind 0.0.0.0
)
if [ "$DEBUG_MODE" = true ]; then
HUGO_ARGS+=(
--logLevel debug
--panicOnWarning
--templateMetrics
--templateMetricsHints
--ignoreCache
--noHTTPCache
--renderStaticToDisk
-D
-E
)
fi
hugo "${HUGO_ARGS[@]}"