Page generation to use title instead of key
This commit is contained in:
@@ -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="
|
||||
|
||||
Reference in New Issue
Block a user