I am just so sick of all these complicated static site generators forcing you to care about taxonomies and shit like this. All I want is to have a bunch of markdown files and let them use specific templates. That is about it. Nothing fancy!
This generator is not for people who need something more complicated. Use Hugo instead. But if you need a simple blog page that needs to spit out an RSS feed or two and have the option to define different templates for different posts, well then this might be useful to you.
The only thing hard about this project is the spelling of its name.
Some facts (will be more clear when you read the whole readme):
- You can nest your markdown file under
contentfolder. You can use subfolders as well. Final URL will not be affected by putting markdown files in subfolders. publicfolder gets automatically created onjbmafp --build.- All files in
staticfolder will be moved to the root ofpublicfolder. - When you provide
urlin your markdown files, this will create these files in the root ofpublicfolder. No nesting allowed. - Comes with a small embedded HTTP server you can invoke with
jbmafo --serverwhich will server contents frompublicfolder. Good for testing stuff. - After you have made your site you can easily create new content with
jbmafp --new "My new shitty title". This will create a new markdown file incontentfolder.
git clone git@github.com:mitjafelicijan/jbmafp.git
cd jbmafp
go install .- Go to your projects folder or wherever you want to place the site.
mkdir my-shitty-website
cd my-shitty-website
jbmafp --init
jbmafp --build- Check out
publicfolder and you will see a website. That is about it. - You can also do
jbmafp --helpto see all the option.
- Posts go into
contentfolder. - Each post must have fields defined between
---block. All of the fields are required. If you have ever used Hugo, this is the same thing. Below is examplecontent/first.md.
---
title: "My first post"
url: first.html
date: 2023-06-29T14:51:39+02:00
type: post
draft: false
---
This is my first post. It ain't much but it's an honest post.typeis used all over the place. It is used to define a template file of the page that will be generated. If type ispostthen the program will loadtemplates/post.htmlto handle generation of the page.- You can use whatever name you want. I use
note,postas types to separate all the pages into categories. typeis also used inside templates like:<ul> {{ range .Pages }} {{ if eq .Type "post" }} <li><a href="/{{ .RelPermalink }}">{{ .Title }}</a></li> {{ end }} {{ end }} </ul>
- This is also use for generating RSS feed. Check
templates/index.xmlto see the example. - This opens door to quite versatile build option.
- You can trigger additional generation of content under
extrasfield inconfig.yamlfile. RSS feed gets generated this way.templatefield tells generator which file intemplatesfolder to use andurltells generator what the file should be called when its saved.
Config {
Title string
Description string
BaseURL string
Language string
Highlighting string
Minify bool
}Using it inside of a template.
<div>{{ .Config.Language }}</div>Page {
Filepath string
Raw string
HTML template.HTML
Text string
Summary string
Meta map[string]interface{}
Title string
RelPermalink string
Type string
Created time.Time
Draft bool
}Using it inside of a template.
{{ range .Pages }}
{{ if eq .Type "post" }}
<li>
<a href="/{{ .RelPermalink }}">{{ .Title }}</a>
<div>{{ .Created.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</div>
</li>
{{ end }}
{{ end }}That .Format shenanigas are used for formatting time.Time type. You can read
more about it on https://gosamples.dev/date-time-format-cheatsheet/.
Payload {
Config
Page
Pages
}- first (gets first N posts)
- last (gets last N posts)
- random (gets random N posts)
- filterbytype (get just the posts with specific type)
<!-- First 10 pages -->
{{ range .Pages | first 10 }}
{{ if and (eq .Type "post") (not .Draft) }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
{{ end }}
<!-- Last 10 pages -->
{{ range .Pages | last 10 }}
{{ if and (eq .Type "post") (not .Draft) }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
{{ end }}
<!-- Random 10 pages -->
{{ range .Pages | random 10 }}
{{ if and (eq .Type "post") (not .Draft) }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
{{ end }}
<!-- Filter by type -->
{{ range .Pages | filterbytype "post" }}
{{ if not .Draft }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
{{ end }}
<!-- Chain multiple together -->
{{ range .Pages | filterbytype "post" | random 20 | first 5 }}
{{ if not .Draft }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
{{ end }}jbmafp was written by Mitja Felicijan and is released under the BSD zero-clause license, see the LICENSE file for more information.
