| Crates.io | simple-web |
| lib.rs | simple-web |
| version | 0.5.2 |
| created_at | 2025-10-08 23:37:37.006969+00 |
| updated_at | 2025-11-15 17:41:12.491944+00 |
| description | A simple build tool that assembles a static site from components, templates, and data. |
| homepage | |
| repository | https://github.com/Tnixc/simple |
| max_upload_size | |
| id | 1874731 |
| size | 178,728 |
[!WARNING] Probably very buggy, it's very opinionated and not extensible.
A simple build tool that assembles a static site from components, templates, and data. I used it to build v6 of https://enochlau.com
<markdown> element to edit it, and it's reflected in the source code.src
├── data
│ ├── a.md
│ ├── Posts
│ │ ├── advanced-features.md
│ │ ├── getting-started.md
│ │ └── my-first-post.md
│ └── Posts.data.toml
├── pages
│ └── index.html
├── public
│ ├── assets
│ │ └── image.webp
│ ├── favicon.png
│ └── styles.css
└── templates
├── Posts.frame.html
└── Posts.template.html
To use the above, you would run the following command, where target contains a folder src.
simple <build|dev|new> /path/to/target
To use components in markup, do the following:
<Component />
<!-- for a self closing component -->
<Layout><h1>Hello world</h1></Layout>
<!-- for a component which contains a <slot></slot> -->
If no content inside a slot component is provided, it will use the fallbacks
inside the <slot> tags. To access components in folders, use a : to separate
them like so:
<Folder:Component />
To pass props to a component, use the following syntax:
<Component prop="value" />
Which will be accessible in the component as ${prop}.
<!-- e.g. in index.html -->
<-Template{Name} />
Think of this like a for each, where Name will be used to search for
src/data/Name.data.toml to populate instances of
src/templates/Name.template.html
Below is an example of a template file:
<!-- Posts.template.html -->
<article class="post-card">
<a href="${link}">
<h2>${title}</h2>
<p class="meta">
<span class="date">${date}</span>
<span class="author">by ${author}</span>
</p>
<p class="description">${description}</p>
</a>
</article>
Note the ${} items. These are template variables that get populated from your data source.
The recommended approach is to use TOML to specify which markdown files to include, and extract metadata from YAML frontmatter in those files.
src/data/Posts.data.toml - Specifies which files to include and their order:
# List of markdown files to include as blog posts
files = [
"my-first-post.md",
"getting-started.md",
"advanced-features.md"
]
src/data/Posts/my-first-post.md - Markdown file with YAML frontmatter:
---
title: My First Blog Post
description: Welcome to my new blog!
date: Jan 15 2025
author: John Doe
---
# Your Content Here
Your markdown content...
The frontmatter is automatically stripped before rendering and used to generate the data for templating. The following fields are auto-generated:
--entry-path: Set to the markdown file path--result-path: Set to content/{filename}.htmllink: Set to ./content/{filename}.htmlAll other frontmatter fields (like title, description, date, author) are available as template variables.
Required fields: Only title is required in the frontmatter.
<markdown> componentThere's also a <markdown> component:
<markdown>
# Hello world
<img src="image.webp" alt="alt" />
</markdown>
Will render out to:
<h1>Hello world</h1>
<img src="image.webp" alt="alt" />
[!NOTE] You can double click on a rendered markdown element and edit it from the web. The changes will be reflected in the source file. It is a bit flakely with escaped html entities, so try to avoid using those.
When using markdown files with frontmatter as shown above, the program will look for a frame file at src/templates/Posts.frame.html to wrap the rendered content. Inside the frame file, the string ${--content} will be replaced with the rendered markdown content.
The frame file can use any of the frontmatter variables (like ${title}, ${date}, etc.) as well as the special ${--content} variable. This allows you to create a consistent layout for all your blog posts while keeping the content in separate markdown files.
Syntax highlighting is supported. It outputs to codeblocks with the syntect highlighting classes. There's tools to convert vscode themes to .tmTheme(textmate theme) files into the css. I made a web app for the process.
Components, templates, and data must following CamalCase, not contain spaces,
and cannot start with a number. They can contain underscores.