mirror of
https://github.com/jackyzha0/hugo-obsidian.git
synced 2024-06-14 11:42:35 +03:00
Add aliases support
This commit is contained in:
parent
a7bc6ab3db
commit
e9e83ce393
1
main.go
1
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
|
||||
|
8
walk.go
8
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user