Documentation
¶
Overview ¶
Package mdgo is a program to write static web server with embedded files using markdown markup languages.
For more information see the README file at the page repository https://sr.ht/~shulhan/mdgo.
Index ¶
Constants ¶
const (
// DefaultRoot define default Root value for GenerateOptions.
DefaultRoot = "."
)
const (
Version = "0.1.0"
)
Variables ¶
This section is empty.
Functions ¶
func Convert ¶
func Convert(opts *ConvertOptions) (err error)
Convert all markup files inside directory "dir" recursively into HTML files using ConvertOptions HtmlTemplate file as base template. If HtmlTemplate is empty it will default to use embedded HTML template. See template_index_html.go for template format.
func GoEmbed ¶
func GoEmbed(opts *EmbedOptions) (err error)
GoEmbed generate a static Go file that embed all files inside Root except the one that being excluded explicitly by ConvertOptions Exclude.
It convert all markup files inside directory "dir" into HTML files, recursively, and then embed them into Go file defined by EmbedOptions.GoFileName.
If HtmlTemplate option is empty it default to use embedded HTML template. See template_index_html.go for template format.
func Serve ¶
func Serve(opts *ServeOptions) (err error)
Serve the content at directory "dir" using HTTP server at specific "address".
func Watch ¶
func Watch(opts *ConvertOptions) (err error)
Watch any changes on markup files on directory Root recursively and changes on the HTML template file. If there is new or modified markup files it will convert them into HTML files using HTML template automatically.
If the HTML template file modified, it will re-convert all markup files. If the HTML template file deleted, it will replace them with internal, default HTML template.
Types ¶
type ConvertOptions ¶
type ConvertOptions struct { // Root directory where its content will be embedded into Go source // code. // Default to DefaultRoot if its empty. Root string // Exclude define regular expresion to exclude certain paths from // being scanned. Exclude string // HtmlTemplate the HTML template to be used when converting markup // file into HTML. // If empty it will default to use embedded HTML template. // See template_index_html.go for template format. HtmlTemplate string // contains filtered or unexported fields }
ConvertOptions define the options to use on Convert function.
type EmbedOptions ¶
type EmbedOptions struct { ConvertOptions // PackageName the name of package in Go generated source code. // Default to memfs.DefaultEmbedPackageName if its empty. PackageName string // GenVarName the name of variable where all files in Root will be // stored. // Default to memfs.DefaultEmbedVarName if its empty. VarName string // GenGoFileName the file name of Go source code will be written. // Default to memfs.DefaultEmbedGoFileName if its empty. GoFileName string }
EmbedOptions define the options for calling GoEmbed function.
type ServeOptions ¶
type ServeOptions struct { ConvertOptions // Mfs contains pointer to variable generated from Generate. // This option is used to use embedded files for serving on HTTP. Mfs *memfs.MemFS // Address to listen and serve for HTTP request. Address string }
ServeOptions contains the options to use on Serve function.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
mdgo
mdgo is a CLI to convert, embed, and/or serve a directory that contains markup files, as HTML files.
|
mdgo is a CLI to convert, embed, and/or serve a directory that contains markup files, as HTML files. |
mdgo-example
Program mdgo-example provide an example on how to build a binary that include the static, generated .go file.
|
Program mdgo-example provide an example on how to build a binary that include the static, generated .go file. |
internal
|
|