mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-10-30 19:56:16 +00:00
36 lines
776 B
Go
36 lines
776 B
Go
package util
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
func SetDefaultHeaderLinks() {
|
|
HeaderLinks = []HeaderLink{
|
|
{"/", SiteName},
|
|
{"/recent-changes", "Recent changes"},
|
|
{"/list", "All hyphae"},
|
|
{"/random", "Random"},
|
|
}
|
|
}
|
|
|
|
// rocketlinkλ is markup.Rocketlink. You have to pass it like that to avoid cyclical dependency.
|
|
func ParseHeaderLinks(text string, rocketlinkλ func(string, string) (string, string, string)) {
|
|
HeaderLinks = []HeaderLink{}
|
|
for _, line := range strings.Split(text, "\n") {
|
|
if strings.HasPrefix(line, "=>") {
|
|
href, text, _ := rocketlinkλ(line, HeaderLinksHypha)
|
|
HeaderLinks = append(HeaderLinks, HeaderLink{
|
|
Href: href,
|
|
Display: text,
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
type HeaderLink struct {
|
|
Href string
|
|
Display string
|
|
}
|
|
|
|
var HeaderLinks []HeaderLink
|