Gozer é um gerador de sites estáticos rápido e simples escrito em Golang.
Exemplos de sites usando Gozer:
Você pode instalar o Gozer instalando primeiro um compilador Go e depois executando:
go install git.sr.ht/~dvko/gozer@latest
Execute gozer new
para gerar rapidamente uma estrutura de diretório vazia.
├── config.toml # Configuration file
├── content # Posts and pages
│ └── index.md
├── public # Static files
└── templates # Template files
└── default.html
Em seguida, execute gozer build
para gerar seu site.
Quaisquer arquivos Markdown colocados em seu diretório content/
resultarão em uma página HTML em seu diretório build após a execução de gozer build
.
Por exemplo:
content/index.md
cria um arquivo build/index.html
para que seja acessível via HTTP em /
content/about.md
cria um arquivo build/about/index.html
para que seja acessível via HTTP em /about/
. Execute gozer
sem argumentos para visualizar o texto de ajuda.
Gozer - a fast & simple static site generator
Usage: gozer [OPTIONS] <COMMAND>
Commands:
build Deletes the output directory if there is one and builds the site
serve Builds the site and starts an HTTP server on http://localhost:8080
new Creates a new site structure in the given directory
Options:
-r, --root <ROOT> Directory to use as root of project (default: .)
-c, --config <CONFIG> Path to configuration file (default: config.toml)
Cada arquivo em seu diretório content/
deve terminar em .md
e ter o cabeçalho TOML especificando o título da página:
+++
title = " My page title "
+++
Page content here.
O modelo padrão para cada página é default.html
. Você pode substituí-lo definindo a variável template
em seu front-mate.
+++
title = " My page title "
template = " special-page.html "
+++
Page content here.
Os modelos são desenvolvidos pelo pacote html/template
padrão do Go, então você pode usar todas as ações descritas aqui.
Cada modelo recebe o seguinte conjunto de variáveis:
Pages # Slice of all pages in the site
Posts # Slice of all posts in the site (any page with a date in the filename)
Site # Global site properties: Url, Title
Page # The current page: Title, Permalink, UrlPath, DatePublished, DateModified
Title # The current page title, shorthand for Page.Title
Content # The current page's HTML content.
A variável Page
é uma instância do objeto abaixo:
type Page struct {
// Title of this page
Title string
// Template this page uses for rendering. Defaults to "default.html".
Template string
// Time this page was published (parsed from file name).
DatePublished time.Time
// Time this page was last modified on the filesystem.
DateModified time.Time
// The full URL to this page, including the site URL.
Permalink string
// URL path for this page, relative to site URL
UrlPath string
// Path to source file for this page, relative to content root
Filepath string
}
Para mostrar uma lista das 5 postagens mais recentes:
{{ range (slice .Posts 0 5) }}
<a href="{{ .Permalink }}">{{ .Title }}</a> <small>{{ .DatePublished.Format "Jan 02, 2006" }}</small><br />
{{ end }}
O desenvolvimento do Gozer acontece no Sourcehut. Patches são aceitos por e-mail.
Gozer é de código aberto sob a licença do MIT.