I have some posts with non-English titles, but I'd like their URLs to use short ASCII slugs. Currently the sulg is computed from the post title:
|
def defaultPostName (date : Date) (title : String) : String := |
|
s!"{date.year}-{date.month}-{date.day}-{slugifyTitle title}" |
|
|
|
structure Config where |
|
destination : System.FilePath := "./_site" |
|
showDrafts : Bool := false |
|
postName : Date → String → String := defaultPostName |
|
remoteInfoConfigPath : Option System.FilePath := none |
|
verbose : Bool := false |
|
deriving Inhabited |
While overriding postName can customize the generated name, it only gets the date and title, so the slug has to live somewhere else. And more importantly, Config now seems to be an internal thing:
|
def blogMain (theme : Theme) (site : Site) (linkTargets : Code.LinkTargets TraverseContext := {}) |
|
(options : List String) (components : Components := by exact %registered_components) |
|
(header : String := Html.doctype) : |
|
IO UInt32 := |
|
withLogger fun logger => do |
|
let cfg ← opts {} options |
|
let (site, xref) ← site.traverse cfg components |>.run logger |
There's no way to pass it as argument, so I'm not sure how to modify postName.
I thought it would be nice to add an optional slug to Post.Meta, so this would get /blog/1980-01-01-test/ naturally:
#doc (Post) "测试" =>
%%%
authors := ["foo"]
date := { year := 1980, month := 1, day := 1 }
slug := "test"
%%%
But I'm not sure if there's already a good way to extend post metadata downstream (without defining a new blog genre).
I have some posts with non-English titles, but I'd like their URLs to use short ASCII slugs. Currently the sulg is computed from the post title:
verso/src/verso-blog/VersoBlog/Basic.lean
Lines 222 to 231 in ffd58ff
While overriding
postNamecan customize the generated name, it only gets the date and title, so the slug has to live somewhere else. And more importantly,Confignow seems to be an internal thing:verso/src/verso-blog/VersoBlog.lean
Lines 843 to 849 in ffd58ff
There's no way to pass it as argument, so I'm not sure how to modify
postName.I thought it would be nice to add an optional
slugtoPost.Meta, so this would get/blog/1980-01-01-test/naturally:But I'm not sure if there's already a good way to extend post metadata downstream (without defining a new blog genre).