Statue Static Site Generator

repository·main·Indexed 41 days ago

https://github.com/accretional/statue

A high-performance static site generator (SSG) version 0.2.15 that uses Markdown for content, Svelte for components, Tailwind for styling, and Pagefind for search. It integrates with SvelteKit and supports advanced features like SQLite dynamic components with OPFS caching and remote iframe previews for specialized templates.

Tokens
91.8K
Snippets
305
Records
367
Agent score
51%

What's inside Statue

  1. What is a Statue theme?

    main
    A theme in Statue is a CSS file that defines color values for a set of required CSS custom properties (variables). Because all Statue components rely on these variables, changing the theme updates the appearance of the entire site, including backgrounds, text, brand accents, borders, and hero gradients.
  2. Manage site content and assets

    main

    Statue sites use a specific directory structure for content and static assets:

    • Assets: Place images, favicons, and logos in the static/ directory. Replace static/favicon.png with your own.
    • Content: Markdown files reside in the content/ directory.
      • Delete placeholder files like content/example.md or content/blog/hello-world.md.
      • Organize your own content into subdirectories (e.g., content/blog/, content/docs/, content/projects/).
    • Routes: Svelte pages are located in src/routes/. You can modify the homepage in src/routes/+page.svelte or the footer in src/routes/+layout.svelte.
    content/
    ├── blog/my-first-post.md
    ├── docs/guide.md
    └── projects/project-one.md
  3. Understand Statue routing types

    main

    Statue uses two distinct routing mechanisms that work together:

    1. Content Routes (Automatic): Any markdown file placed in the content/ directory is automatically converted into a page. The folder structure within content/ directly maps to the URL path.

      • content/blog/my-post.md → /blog/my-post
      • content/about.md → /about
    2. Custom Routes (Manual): Standard SvelteKit routes defined in src/routes/ allow you to create pages that are not based on markdown files (e.g., a pricing page or a contact page).

      • src/routes/pricing/+page.svelte → /pricing

    Route Priority Warning: If a custom Svelte route and a markdown content file share the same path (e.g., src/routes/about/+page.svelte and content/about.md), the Svelte page takes precedence and the markdown content will not be rendered.

    content/blog/my-post.md    →  /blog/my-post
    content/docs/guide.md      →  /docs/guide
    content/about.md           →  /about
  4. How Statue's template-based architecture works

    main

    Statue is a Template-Based Static Site Generator. The architecture is split into two main parts:

    1. Core Logic: Resides in src/lib/ (containing Components, CMS, and Styles). This logic is shared across all templates.
    2. Templates:
      • Default Template: Defined by the src/routes/ and content/ folders located in the root of the repository.
      • Other Templates: Located in templates/<template-name>/. Each template contains its own routes, content, and config files.
  5. Understand the Statue project structure

    main

    A standard Statue project follows this directory layout:

    • content/: Contains all .md files for your site content.
    • src/lib/index.css: The entry point for your site's theme styling.
    • src/routes/: Contains SvelteKit route files:
      • +page.svelte: The homepage.
      • [directory]/+page.svelte: Directory-level pages.
      • [...slug]/+page.svelte: Individual content pages.
    • static/: Holds static assets like images and favicons.
    • site.config.json: The global configuration file.
  6. Use post-setup.sh for automatic template configuration

    main

    You can include a post-setup.sh script in your template directory to perform tasks immediately after a user initializes the template (e.g., fetching GitHub data or running migrations).

    Behavior:

    • The script is executed by the CLI during npx statue init.
    • It is not copied to the user's project.
    • It has access to the PROJECT_DIR environment variable, which is the absolute path to the user's new project.

    Best Practices:

    • Keep it non-interactive (no read prompts).
    • Handle errors gracefully (e.g., command || echo 'warning').
    • Do not require user input.
    #!/bin/bash
    # templates/your-template/post-setup.sh
    
    # $PROJECT_DIR is the absolute path to the user's project
    cd "$PROJECT_DIR"
    
    if [ -f "./scripts/setup.sh" ]; then
        bash "./scripts/setup.sh"
    fi
  7. How content routing works via catch-all routes

    main

    Statue relies on two specific catch-all routes to bridge the content/ directory to the web:

    • Individual Pages ([...slug]/+page.svelte): Matches specific markdown files (e.g., /about matches content/about.md).
    • Directory Listings ([directory]/+page.svelte): Matches directory paths to list all markdown files within them (e.g., /blog matches all files in content/blog/).

    Note: Do not modify the +page.server.js files associated with these routes, as they contain the core logic for loading and parsing markdown content.

  8. Accessibility requirements for themes

    main

    Themes must meet WCAG AA standards for color contrast to ensure readability:

    • Normal text: Contrast ratio ≥ 4.5:1
    • Large text: Contrast ratio ≥ 3:1

    Key combinations to check:

    • --color-foreground on --color-background
    • --color-on-primary on --color-primary
    • --color-muted on --color-background
  9. Use Remote Agent Cards via iframe

    main

    The brokerage.agents.items[] array in site.config.json supports two modes for displaying agents:

    1. Local card mode: Provide standard fields like name, title, image, email, and phone to render a native card.
    2. Remote iframe mode: Provide a remoteUrl. When this field is present, the agent card is rendered from the remote site using an <iframe>.

    Configuring the Remote Fragment

    By default, the template appends #agent-preview-mobile-card to the remoteUrl to target a specific part of the remote page. You can override this fragment using the brokerage.agents.remotePreviewFragment configuration key.

    Local Development

    If your remote URL points to a local instance of the real-estate-agent template, use http://localhost:3000 during development.

    {
      "brokerage": {
        "agents": {
          "remotePreviewFragment": "#custom-fragment",
          "items": [
            {
              "remoteUrl": "https://agent-profile.com/jane-doe"
            }
          ]
        }
      }
    }
  10. Use Directory components for listing pages

    main

    Statue provides several components for building directory listing pages:

    • DirectoryHeader: Displays the directory name.
    • SubDirectories: A grid of subdirectory cards.
    • DirectoryContent: A grid of content cards within a directory.
    <!-- DirectoryHeader Example -->
    <DirectoryHeader title="Blog Posts" />
    
    <!-- SubDirectories Example -->
    <SubDirectories subDirectories={[{ title: 'Tutorials', url: '/docs/tutorials' }]} />
    
    <!-- DirectoryContent Example -->
    <DirectoryContent content={[{ url: '/docs/guide', metadata: { title: 'Guide', description: 'Getting started' } }]} />