mirror of
https://github.com/kovetskiy/mark.git
synced 2026-05-04 06:22:35 +00:00
feat: add flag to append hash to pages to ensure unique titles
This commit is contained in:
committed by
Manuel Rüger
parent
2af50c627f
commit
b0f337c4a3
10
main.go
10
main.go
@@ -81,6 +81,12 @@ var flags = []cli.Flag{
|
||||
Usage: "extract page title from a leading H1 heading. If no H1 heading on a page exists, then title must be set in the page metadata.",
|
||||
EnvVars: []string{"MARK_H1_TITLE"},
|
||||
}),
|
||||
altsrc.NewBoolFlag(&cli.BoolFlag{
|
||||
Name: "title-append-generated-hash",
|
||||
Value: false,
|
||||
Usage: "appends a short hash generated from the path of the page (space, parents, and title) to the title",
|
||||
EnvVars: []string{"MARK_TITLE_APPEND_GENERATED_HASH"},
|
||||
}),
|
||||
altsrc.NewBoolFlag(&cli.BoolFlag{
|
||||
Name: "minor-edit",
|
||||
Value: false,
|
||||
@@ -309,7 +315,7 @@ func processFile(
|
||||
|
||||
parents := strings.Split(cCtx.String("parents"), cCtx.String("parents-delimiter"))
|
||||
|
||||
meta, markdown, err := metadata.ExtractMeta(markdown, cCtx.String("space"), cCtx.Bool("title-from-h1"), parents)
|
||||
meta, markdown, err := metadata.ExtractMeta(markdown, cCtx.String("space"), cCtx.Bool("title-from-h1"), parents, cCtx.Bool("title-append-generated-hash"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -388,7 +394,7 @@ func processFile(
|
||||
}
|
||||
}
|
||||
|
||||
links, err := page.ResolveRelativeLinks(api, meta, markdown, filepath.Dir(file), cCtx.String("space"), cCtx.Bool("title-from-h1"), parents)
|
||||
links, err := page.ResolveRelativeLinks(api, meta, markdown, filepath.Dir(file), cCtx.String("space"), cCtx.Bool("title-from-h1"), parents, cCtx.Bool("title-append-generated-hash"))
|
||||
if err != nil {
|
||||
log.Fatalf(err, "unable to resolve relative links")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user