gen

command module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2020 License: MIT Imports: 8 Imported by: 0

README

cmd gen

Gen logo

cmd gen is a tool to output static htmls from markdown.

Test GoDoc Go Report Card

Installation

go get github.com/Qs-F/gen

Usage

# Example - see _example directory
gen -base _example/ -src _example/content -dst _example/dist

Features

import directive

in front matter, you can import other markdown.

---
import:
- content/a.md
---

Likewise, write the path to the file from base path without first slash.

import is useful, like you can import with namespace. For more cases, please see _example/*/content directory.

---
named: 
  import:
  - content/a.md
---

you can access with {{ .named.hogehoge }} in a.md.
layout directive

layout is optional. If you want to output whole html with embedded markdown content in html file, this helps.

---
title: hello
layout: layout/index.html
---

## Hoge page

This is new page.

write the path of layout file from base without slash in layout.

And in layout file, you have to write special variable {{ .__content__ }} to show markdown content.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>{{ .title }}</title>
</head>
<body>
  <article>
    {{ .__content__ }}
  </article>
</body>
</html>
embedded value

in your markdown file, you can even write following:

---
field1: "{{ .field2 }} is the best"
field2: golang
---

{{ field1 }}

This will be formed out as

<p>golang is the best</p>

more complex example:

content/a.md

---
who: "{{ .name }}"
name: "{{ .b.name }}"
b:
  import:
  - content/b.md
display: "{{ .who }} wrote this file"
---

{{ .display }}

content/b.md

---
name: たふみ
---

then

dist/a.html

<p>たふみ wrote this file</p>

(no dist/b.html, cuz b.md only contains variable.)

Note:

  • You CANNOT use variable for the yaml key. e.g. {{ .key }}: hello is invalid.
  • No DFS implmented, so cyclic import can cause undefined behavior.

License

MIT License

Copyright 2020 de-liKeR / たふみ @CreatorQsF

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
lib
expander/markdown
Package markdown is the expander for markdown to html
Package markdown is the expander for markdown to html
gen
Package gen is the packeg of internal gen
Package gen is the packeg of internal gen
loader/html
Package html is the package for load html
Package html is the package for load html
loader/markdown
Package markdown is the loader of markdown
Package markdown is the loader of markdown

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL