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"`
|
Content string `json:"content"`
|
||||||
LastModified time.Time `json:"lastmodified"`
|
LastModified time.Time `json:"lastmodified"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
|
Aliases []string `json:"aliases"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ContentIndex = map[string]Content
|
type ContentIndex = map[string]Content
|
||||||
|
8
walk.go
8
walk.go
@ -17,6 +17,7 @@ type Front struct {
|
|||||||
Title string `yaml:"title"`
|
Title string `yaml:"title"`
|
||||||
Draft bool `yaml:"draft"`
|
Draft bool `yaml:"draft"`
|
||||||
Tags []string `yaml:"tags"`
|
Tags []string `yaml:"tags"`
|
||||||
|
Aliases []string `yaml:"aliases"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// recursively walk directory and return all files with given extension
|
// 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",
|
Title: "Untitled Page",
|
||||||
Draft: false,
|
Draft: false,
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
|
Aliases: []string{},
|
||||||
}
|
}
|
||||||
body = text
|
body = text
|
||||||
}
|
}
|
||||||
@ -74,12 +76,18 @@ func walk(root, ext string, index bool, ignorePaths map[string]struct{}) (res []
|
|||||||
matter.Tags = []string{}
|
matter.Tags = []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// default aliases
|
||||||
|
if matter.Aliases == nil {
|
||||||
|
matter.Aliases = []string{}
|
||||||
|
}
|
||||||
|
|
||||||
// add to content and link index
|
// add to content and link index
|
||||||
i[source] = Content{
|
i[source] = Content{
|
||||||
LastModified: info.ModTime(),
|
LastModified: info.ModTime(),
|
||||||
Title: title,
|
Title: title,
|
||||||
Content: body,
|
Content: body,
|
||||||
Tags: matter.Tags,
|
Tags: matter.Tags,
|
||||||
|
Aliases: matter.Aliases,
|
||||||
}
|
}
|
||||||
res = append(res, parse(s, root)...)
|
res = append(res, parse(s, root)...)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user