Statue Static Site Generator
repository·main·Indexed 41 days ago
https://github.com/accretional/statueA 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.
What's inside Statue
- 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.
Manage site content and assets
mainStatue sites use a specific directory structure for content and static assets:
- Assets: Place images, favicons, and logos in the
static/directory. Replacestatic/favicon.pngwith your own. - Content: Markdown files reside in the
content/directory.- Delete placeholder files like
content/example.mdorcontent/blog/hello-world.md. - Organize your own content into subdirectories (e.g.,
content/blog/,content/docs/,content/projects/).
- Delete placeholder files like
- Routes: Svelte pages are located in
src/routes/. You can modify the homepage insrc/routes/+page.svelteor the footer insrc/routes/+layout.svelte.
content/ ├── blog/my-first-post.md ├── docs/guide.md └── projects/project-one.md- Assets: Place images, favicons, and logos in the
Understand Statue routing types
mainStatue uses two distinct routing mechanisms that work together:
Content Routes (Automatic): Any markdown file placed in the
content/directory is automatically converted into a page. The folder structure withincontent/directly maps to the URL path.content/blog/my-post.md→/blog/my-postcontent/about.md→/about
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.svelteandcontent/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 → /aboutHow Statue's template-based architecture works
mainStatue is a Template-Based Static Site Generator. The architecture is split into two main parts:
- Core Logic: Resides in
src/lib/(containing Components, CMS, and Styles). This logic is shared across all templates. - Templates:
- Default Template: Defined by the
src/routes/andcontent/folders located in the root of the repository. - Other Templates: Located in
templates/<template-name>/. Each template contains its ownroutes,content, andconfigfiles.
- Default Template: Defined by the
- Core Logic: Resides in
Understand the Statue project structure
mainA standard Statue project follows this directory layout:
content/: Contains all.mdfiles 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.
Use post-setup.sh for automatic template configuration
mainYou can include a
post-setup.shscript 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_DIRenvironment variable, which is the absolute path to the user's new project.
Best Practices:
- Keep it non-interactive (no
readprompts). - 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- The script is executed by the CLI during
How content routing works via catch-all routes
mainStatue 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.,/aboutmatchescontent/about.md). - Directory Listings (
[directory]/+page.svelte): Matches directory paths to list all markdown files within them (e.g.,/blogmatches all files incontent/blog/).
Note: Do not modify the
+page.server.jsfiles associated with these routes, as they contain the core logic for loading and parsing markdown content.- Individual Pages (
How themes control site styling
mainSite styling is managed via CSS imports in
src/lib/index.css. You can switch the entire look of your site by changing the@importstatement to one of the eight built-in themes.Example of importing the blue theme:
@import "statue-ssg/themes/blue.css";Accessibility requirements for themes
mainThemes 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-foregroundon--color-background--color-on-primaryon--color-primary--color-mutedon--color-background
How Statue organizes content and routing
mainStatue uses a file-based routing system where Markdown files located in the
content/directory determine your site's URL structure. There is no database or CMS required; the folder hierarchy directly maps to your website paths.Example Mapping:
content/blog/my-post.mdbecomesyoursite.com/blog/my-postcontent/docs/guide.mdbecomesyoursite.com/docs/guide
Use Remote Agent Cards via iframe
mainThe
brokerage.agents.items[]array insite.config.jsonsupports two modes for displaying agents:- Local card mode: Provide standard fields like
name,title,image,email, andphoneto render a native card. - 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-cardto theremoteUrlto target a specific part of the remote page. You can override this fragment using thebrokerage.agents.remotePreviewFragmentconfiguration key.Local Development
If your remote URL points to a local instance of the
real-estate-agenttemplate, usehttp://localhost:3000during development.{ "brokerage": { "agents": { "remotePreviewFragment": "#custom-fragment", "items": [ { "remoteUrl": "https://agent-profile.com/jane-doe" } ] } } }- Local card mode: Provide standard fields like
Use Directory components for listing pages
mainStatue 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' } }]} />