add public field to adoc header
This commit is contained in:
parent
bc5e56ae26
commit
571c1df0a2
|
@ -2,6 +2,7 @@
|
|||
Erik Winter <ik@erikwinter.nl>
|
||||
2020-12-01
|
||||
:kind: essay
|
||||
:public: yes
|
||||
:tags: asciidoc
|
||||
:project: shitty-ssg
|
||||
:language: EN
|
||||
|
@ -27,6 +28,7 @@ A header consists of the title of the post and various fields of metadata. It lo
|
|||
Erik Winter <info@erikwinter.nl>
|
||||
2020-12-01
|
||||
:kind: note
|
||||
:public: yes
|
||||
:language: EN
|
||||
:project: shitty-ssg
|
||||
:tags: asciidoc, ssg, parser
|
||||
|
@ -38,6 +40,7 @@ It starts with the title on the first line, which is prefixed with `=`, and it e
|
|||
A the attributes of a post are defined as a key-value pair. Each pair gets its own line. The following attributes are supported:
|
||||
|
||||
* `kind` The type of post. Either `note`, `story` or `article`.
|
||||
* `public` Can be exported to sites/systems that other people see. Values are `true`/`yes`, `false`/`no`. Defaults to `false`.
|
||||
* `language` A two letter country code. Only `NL` will have a visible effect, by showing the Dutch flag in various places.
|
||||
* `project` Posts that belong to a personal project.
|
||||
* `tags` A comma separated list of tags.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
Erik Winter <ik@erikwinter.nl>
|
||||
2021-03-09
|
||||
:kind: article
|
||||
:public: yes
|
||||
:tags: golang, asciidoc
|
||||
:project: shitty-ssg
|
||||
:language: en
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
Erik Winter
|
||||
2020-11-09
|
||||
:kind: article
|
||||
:public: yes
|
||||
:tags: productivity, asciidoc, hugo
|
||||
:language: EN
|
||||
:project: shitty-ssg
|
||||
|
|
|
@ -67,6 +67,7 @@ type ADoc struct {
|
|||
Author string
|
||||
Kind Kind
|
||||
Language Language
|
||||
Public bool
|
||||
Path string
|
||||
Date time.Time
|
||||
Tags []Tag
|
||||
|
|
|
@ -128,6 +128,12 @@ func ParseHeader(text string, doc *ADoc) {
|
|||
case strings.HasPrefix(l, ":language:"):
|
||||
s := strings.Split(l, ":")
|
||||
doc.Language = NewLanguage(strings.TrimSpace(s[2]))
|
||||
case strings.HasPrefix(l, ":public:"):
|
||||
s := strings.Split(l, ":")
|
||||
val := strings.TrimSpace(s[2])
|
||||
if val == "yes" || val == "true" {
|
||||
doc.Public = true
|
||||
}
|
||||
case strings.HasPrefix(l, ":tags:"):
|
||||
s := strings.Split(l, ":")
|
||||
t := strings.Split(s[2], ",")
|
||||
|
|
|
@ -39,11 +39,12 @@ func TestNew(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "header",
|
||||
input: "= Title\nT. Test\n2020-10-27\n:tags:\ttag1, tag2\n:kind:\tnote\n:language:\tnl",
|
||||
input: "= Title\nT. Test\n2020-10-27\n:tags:\ttag1, tag2\n:kind:\tnote\n:language:\tnl\n:public: yes",
|
||||
exp: &adoc.ADoc{
|
||||
Title: "Title",
|
||||
Author: "T. Test",
|
||||
Kind: adoc.KIND_NOTE,
|
||||
Public: true,
|
||||
Language: adoc.LANGUAGE_NL,
|
||||
Tags: []adoc.Tag{
|
||||
adoc.Tag("tag1"),
|
||||
|
|
Loading…
Reference in New Issue