From e9e83ce39312ee419c4329c28b2ae1307cc9d085 Mon Sep 17 00:00:00 2001 From: mzietlow <> Date: Sun, 19 Mar 2023 10:57:58 +0100 Subject: [PATCH] Add aliases support --- main.go | 1 + walk.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/main.go b/main.go index d5dfd44..af81985 100644 --- a/main.go +++ b/main.go @@ -35,6 +35,7 @@ type Content struct { Content string `json:"content"` LastModified time.Time `json:"lastmodified"` Tags []string `json:"tags"` + Aliases []string `json:"aliases"` } type ContentIndex = map[string]Content diff --git a/walk.go b/walk.go index 34e3795..369cb03 100644 --- a/walk.go +++ b/walk.go @@ -17,6 +17,7 @@ type Front struct { Title string `yaml:"title"` Draft bool `yaml:"draft"` Tags []string `yaml:"tags"` + Aliases []string `yaml:"aliases"` } // recursively walk directory and return all files with given extension @@ -54,6 +55,7 @@ func walk(root, ext string, index bool, ignorePaths map[string]struct{}) (res [] Title: "Untitled Page", Draft: false, Tags: []string{}, + Aliases: []string{}, } body = text } @@ -74,12 +76,18 @@ func walk(root, ext string, index bool, ignorePaths map[string]struct{}) (res [] matter.Tags = []string{} } + // default aliases + if matter.Aliases == nil { + matter.Aliases = []string{} + } + // add to content and link index i[source] = Content{ LastModified: info.ModTime(), Title: title, Content: body, Tags: matter.Tags, + Aliases: matter.Aliases, } res = append(res, parse(s, root)...) } else {