Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #15 from jackyzha0/draft-support
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzha0 authored Mar 15, 2022
2 parents 458291e + 6caa733 commit 4c48948
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ type Index struct {
}

type Content struct {
Title string `json:"title"`
Content string `json:"content"`
LastModified time.Time `json:"lastmodified"`
Tags []string `json:"tags"`
Title string `json:"title"`
Content string `json:"content"`
LastModified time.Time `json:"lastmodified"`
Tags []string `json:"tags"`
}

type ContentIndex = map[string]Content
Expand All @@ -46,7 +46,7 @@ type ConfigTOML struct {
func getIgnoredFiles(base string) (res map[string]struct{}) {
res = make(map[string]struct{})

source, err := ioutil.ReadFile(base + "/config.toml")
source, err := ioutil.ReadFile(filepath.FromSlash(base + "/config.toml"))
if err != nil {
return res
}
Expand Down
10 changes: 6 additions & 4 deletions walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ func walk(root, ext string, index bool, ignorePaths map[string]struct{}) (res []
m.Handle("---", front.YAMLHandler)
nPrivate := 0

err := filepath.WalkDir(root, func(s string, d fs.DirEntry, e error) error {
err := filepath.WalkDir(root, func(fp string, d fs.DirEntry, e error) error {
if e != nil {
return e
}

// path normalize fp
s := filepath.ToSlash(fp)
if _, ignored := ignorePaths[s]; ignored {
fmt.Printf("[Ignored] %s\n", d.Name())
nPrivate++
Expand Down Expand Up @@ -50,8 +53,8 @@ func walk(root, ext string, index bool, ignorePaths map[string]struct{}) (res []
adjustedPath := UnicodeSanitize(strings.Replace(hugoPathTrim(trim(s, root, ".md")), " ", "-", -1))
i[adjustedPath] = Content{
LastModified: info.ModTime(),
Title: title,
Content: body,
Title: title,
Content: body,
}
} else {
fmt.Printf("[Ignored] %s\n", d.Name())
Expand All @@ -78,4 +81,3 @@ func getText(dir string) string {

return string(fileBytes)
}

0 comments on commit 4c48948

Please sign in to comment.