cdelorme 8f8f82fa26 fix library reference from command | %!s(int64=7) %!d(string=hai) anos | |
---|---|---|
.. | ||
main.go | %!s(int64=7) %!d(string=hai) anos | |
main_test.go | %!s(int64=7) %!d(string=hai) anos | |
readme.md | %!s(int64=7) %!d(string=hai) anos | |
template.tmpl | %!s(int64=7) %!d(string=hai) anos |
This is the cli implementation and interface to the staticmd library.
It exposes the libraries functionality and handles inputs and outputs through command line.
There are other tools in multiple languages that already provide full-featured static generated assets with support for far more complex use cases:
While the original point of this project was self-education, it still serves as a simple and compact shippable utility at only 722
lines of code (including tests and comments). With recent updates it is now much cleaner and fully tested.
It has a minimal dependency footprint:
This project assumes some defaults behaviors:
public/
for the output pathMost of these default behaviors can be overridden with command line parameters.
The only required parameter is the path to a template file. An example has been included with the project.
If run within a repository it will attempt to grab a short-hash for the version, otherwise it generates a unix timestamp.
It assumes the index files are index.html
. If no match is found then no table of contents is created and no references to that folder will be created at the parent either even if it contains other markdown files.
Currently it attempts to generate multiple pages in parallel.
Install the utility:
go get -u github.com/cdelorme/staticmd/...
The utility has builtin help to assist with using it:
staticmd help
_It uses the go-log
package, which means you can enable logging by setting LOG_LEVEL=debug
(or any other valid log level)._
You can use it to generate a single-page document that can be printed as a PDF and distributed with ease:
staticmd -t template.tmpl -s -c src/
This will generate a single file inside src/
.
This code has unit tests that can easily be executed:
LOG_LEVEL=silent go test -v -race -cover