add tags support

This commit is contained in:
Jacky Zhao 2023-03-16 10:25:45 -07:00
parent e45dd6c7c8
commit 1661db2ac3
2 changed files with 5 additions and 3 deletions

View File

@ -1,6 +1,5 @@
# File generated by github.com/posener/goaction. DO NOT EDIT. # File generated by github.com/posener/goaction. DO NOT EDIT.
FROM golang:1.16-alpine3.14 FROM golang:1.16-alpine3.14
RUN apk add git RUN apk add git

View File

@ -16,6 +16,7 @@ import (
type Front struct { type Front struct {
Title string `yaml:"title"` Title string `yaml:"title"`
Draft bool `yaml:"draft"` Draft bool `yaml:"draft"`
Tags []string `yaml:"tags"`
} }
// recursively walk directory and return all files with given extension // recursively walk directory and return all files with given extension
@ -52,6 +53,7 @@ func walk(root, ext string, index bool, ignorePaths map[string]struct{}) (res []
matter = Front{ matter = Front{
Title: "Untitled Page", Title: "Untitled Page",
Draft: false, Draft: false,
Tags: []string{},
} }
body = text body = text
} }
@ -72,6 +74,7 @@ func walk(root, ext string, index bool, ignorePaths map[string]struct{}) (res []
LastModified: info.ModTime(), LastModified: info.ModTime(),
Title: title, Title: title,
Content: body, Content: body,
Tags: matter.Tags,
} }
res = append(res, parse(s, root)...) res = append(res, parse(s, root)...)
} else { } else {