feat: add sb front matter

This commit is contained in:
Krispire Admin
2026-06-14 15:32:29 +05:30
parent 4946ce1062
commit 93e92c610c
2 changed files with 36 additions and 16 deletions
+12 -3
View File
@@ -427,11 +427,20 @@ func indexProse(sugar *zap.SugaredLogger, tsClient *typesense.Client, mongoDB *r
content = joinParagraphs(strs)
}
// Build URL: KB uses /books/kb/{volume}/{slug}, others use /books/{book}/{slug}
// Build URL: KB uses /books/kb/{volume}/{slug}; chapter summaries map
// their "<lila>-<n>" slug to the chapter landing page; others use
// /books/{book}/{slug}.
var proseURL string
if book == "kb" {
switch {
case book == "kb":
proseURL = fmt.Sprintf("/books/kb/%d/%s", volume, slug)
} else {
case docType == "chapter-summary":
if parts := strings.SplitN(slug, "-", 2); len(parts) == 2 {
proseURL = fmt.Sprintf("/books/%s/%s/%s", book, parts[0], parts[1])
} else {
proseURL = fmt.Sprintf("/books/%s/%s", book, slug)
}
default:
proseURL = fmt.Sprintf("/books/%s/%s", book, slug)
}