Page generation to use title instead of key

This commit is contained in:
2026-05-22 13:21:08 +02:00
parent 835d1153f0
commit a17477cff1
4 changed files with 104 additions and 20 deletions
+23
View File
@@ -330,6 +330,13 @@ func collectLocalPages(sourceDir string, namespaces []string) (map[string]wikiDe
return err
}
content := string(raw)
if markerPageID := extractWikiPageID(content); markerPageID != "" {
pageID = markerPageID
namespace = strings.SplitN(pageID, ":", 2)[0]
if _, ok := namespaceSet[namespace]; !ok {
return nil
}
}
pages[pageID] = wikiDeployPage{
PageID: pageID,
Title: extractPageTitle(content, pageID),
@@ -924,6 +931,22 @@ func renderArchivedWikiPage(pageID, title string) string {
}, "\n"))
}
func extractWikiPageID(content string) string {
const pageMarker = "sow-topdata-wiki:page="
start := strings.Index(content, pageMarker)
if start < 0 {
return ""
}
value := content[start+len(pageMarker):]
if end := strings.Index(value, "-->"); end >= 0 {
value = value[:end]
}
if fields := strings.Fields(value); len(fields) > 0 {
return strings.Trim(strings.TrimSpace(fields[0]), `"`)
}
return ""
}
func extractWikiPagePublicPath(content string) string {
const pageMarker = "sow-topdata-wiki:page="
const pathField = "public_path="