Granita
A super-simple static site generator, with sensible opinionated defaults.
Installation
pip install granita
Quickstart
Run the following commands in your terminal, then open the file my_app/public/index.html in your browser.
granita init my_app
cd my_app
granita build
What this is
At a basic level, you write Markdown in the pages directory, and Granita combines them with HTML templates from the templates directory.
For example, take the following Markdown:
# Hello world!
> *I'm learning how to use [Granita](https://github.com/apple-phi/granita)*
This would be translated into HTML before being inserted inside the <Content/> element in the template.
By default, if a template is not specified, Granita will try to find and use file called default.html in your templates directory.
Files listed in the static directory will be copied as-is to the output public directory.
Frontmatter
To specify your own parameters, you can use a format called frontmatter. It looks like this:
---
title: "My app"
template: my_template.html
---
# Hello world!
> *I'm learning how to use [Granita](https://github.com/apple-phi/granita)*
title and template are treated specially by Granita. Here's what they do:
titlespecifies the title of the webpage, by creating a<title>element if it doesn't already exist in the template.templatespecifies the HTML template to embed the Markdown in, with the path relative to thetemplatesdirectory.
Additionally, the frontmatter keys are treated as CSS selectors for prepending content to the template. So if you had the following frontmatter:
---
"#my_element": "some text"
---
Then the element with the id my_element will have the text some text prepended inside it.
And this will happen for all elements matched by the CSS selector. For example, if you duplicate the <Content/> tag in the default template generated by granita init and rebuild, then you will see two copies of the page content.
Further configuration
If you are unsatisfied with the default paths and settings, you can create a granita.config.json file to override them. Here's what the default configuration looks like:
{
"pages": "pages", // path to pages dir
"static": "static", // path to static dir
"public": "public", // path to output dir
"templates": "templates", // path to template dir
"default-template": "default.html", // fallback template path
"content-selector": "Content", // CSS selector to insert Markdown into
"global-stylesheet": null, // a stylesheet to be applied to all templates
"extra-data": {} // key : value pairs of CSS selector : HTML data
}
You don't have to provide customisation for all settings; the defaults will be used if left unspecified.
License
MIT License, which can be found here
© Copyright 2021, apple-phi.
Metadata
Release files for granita 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| granita-0.3.0.tar.gz | 4.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| granita-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.8 kB
Release files / granita-0.3.0.tar.gz
| Download URL | granita-0.3.0.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
00fd87ba374d2a2bd05e544419818bcad835ba55e61dc8239573de596846574c
|
|
BLAKE2b-256 checksum How to use checksums |
b380e8b0efb259ca4fc11ddc0ed8611fcaf4bcdc78b62773c699bffa2ac01765
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.27.1
|
Release files / granita-0.3.0-py3-none-any.whl
| Download URL | granita-0.3.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3e53d272b6652a5e3b133412aa1991ea95fac1fbaf9931b3b8991f9f200c1e06
|
|
BLAKE2b-256 checksum How to use checksums |
91e42403d5073d2949481ec9fff649f055857967c4798f2881445bf439abf6c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.27.1
|
Security for granita 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.