diff --git a/README.md b/README.md index f025688..c055513 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,13 @@ To disable automatic browser reload on file changes (useful for stable editing): go-grip --no-reload README.md ``` +To use a formatted version of the Markdown filename as the browser page title +(`my-guide_v2.md` becomes `My Guide V2`): + +```bash +go-grip --filename-title my-guide_v2.md +``` + To terminate the current server simply press `CTRL-C`. ## :pencil: Examples diff --git a/cmd/root.go b/cmd/root.go index 12b04ed..7013d33 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -17,6 +17,7 @@ var rootCmd = &cobra.Command{ port, _ := cmd.Flags().GetInt("port") boundingBox, _ := cmd.Flags().GetBool("bounding-box") noReload, _ := cmd.Flags().GetBool("no-reload") + filenameTitle, _ := cmd.Flags().GetBool("filename-title") var file string if len(args) == 1 { @@ -24,7 +25,7 @@ var rootCmd = &cobra.Command{ } parser := internal.NewParser() - server := internal.NewServer(host, port, boundingBox, browser, !noReload, parser) + server := internal.NewServer(host, port, boundingBox, browser, !noReload, filenameTitle, parser) return server.Serve(file) }, } @@ -42,4 +43,5 @@ func init() { rootCmd.Flags().IntP("port", "p", 6419, "Port to use") rootCmd.Flags().Bool("bounding-box", true, "Add bounding box to HTML") rootCmd.Flags().Bool("no-reload", false, "Disable automatic browser reload on file changes") + rootCmd.Flags().Bool("filename-title", false, "Use the Markdown filename as the HTML page title") } diff --git a/defaults/templates/layout.html b/defaults/templates/layout.html index f53e6fa..94a1cc0 100644 --- a/defaults/templates/layout.html +++ b/defaults/templates/layout.html @@ -3,7 +3,7 @@
-