Skip to content

Commit

Permalink
unquotedProperties cli param
Browse files Browse the repository at this point in the history
  • Loading branch information
viktomas committed Sep 25, 2022
1 parent 057a2f4 commit 78ea42c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func findMatchingFiles(rootPath string, substring string) ([]string, error) {
func main() {
graphPath := flag.String("graphPath", "", "[MANDATORY] Path to the root of your logseq graph containing /pages and /journals directories.")
blogFolder := flag.String("blogFolder", "", "[MANDATORY] Folder where this program creates a new subfolder with public logseq pages.")
unquotedProperties := flag.String("unquotedProperties", "", "comma-separated list of logseq page properties that won't be quoted in the markdown frontmatter, e.g. 'date,public,slug")
flag.Parse()
if *graphPath == "" || *blogFolder == "" {
log.Println("mandatory argument is missing")
Expand All @@ -77,13 +78,20 @@ func main() {
if err != nil {
log.Fatalf("Error when creating parent directory for %q: %v", dest, err)
}
err = writeStringToFile(dest, render(result, []string{"date", "slug"}))
err = writeStringToFile(dest, render(result, parseUnquotedProperties(*unquotedProperties)))
if err != nil {
log.Fatalf("Error when copying file %q: %v", dest, err)
}
}
}

func parseUnquotedProperties(param string) []string {
if param == "" {
return []string{}
}
return strings.Split(param, ",")
}

func render(p page, dontQuote []string) string {
attributeBuilder := strings.Builder{}
for name, value := range p.attributes {
Expand Down

0 comments on commit 78ea42c

Please sign in to comment.