File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ type ParserConfig struct {
5858 SiteTitle string `yaml:"siteTitle"`
5959 Description string `yaml:"description"`
6060 Repo string `yaml:"repo"`
61+ BaseURL string `yaml:"baseUrl"`
6162}
6263
6364type File struct {
@@ -183,6 +184,8 @@ type RenderContext struct {
183184 Content template.HTML
184185 OutDir string
185186 OutFile string
187+ BaseURL string
188+ Link string
186189}
187190
188191func (p * Parser ) Render () error {
@@ -223,6 +226,7 @@ func (p *Parser) Render() error {
223226 Content : template .HTML (o ),
224227 OutDir : outDir ,
225228 OutFile : outFile ,
229+ Link : f .Path ,
226230 }
227231
228232 rndCtxs = append (rndCtxs , & ctx )
@@ -280,13 +284,14 @@ func (p *Parser) Render() error {
280284 ctx .SiteTitle = p .Config .SiteTitle
281285 ctx .Description = p .Config .Description
282286 ctx .MenuItems = menuItems
287+ ctx .BaseURL = p .Config .BaseURL
283288
284289 for _ , mit := range menuItems {
285290 if mit .Group {
286291 for _ , cmit := range mit .Items {
287- cmit .Active = cmit .Title == ctx .Title
292+ cmit .Active = cmit .Link == ctx .Link
288293 }
289- } else if mit .Title == ctx .Title {
294+ } else if mit .Link == ctx .Link {
290295 mit .Active = true
291296 } else {
292297 mit .Active = false
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ const BaseTemplate = `<!DOCTYPE html>
66 <meta charset="UTF-8">
77 <title>{{ .Title }}</title>
88 {{ if .Description }}<meta name="description" content="{{ .Description }}">{{ end }}
9+ {{ if .BaseURL }}<base href="{{ .BaseURL }}" />{{ end }}
910 <link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
1011 <meta name="viewport" content="width=device-width, initial-scale=1">
1112 <meta name="theme-color" content="#fafafa">
You can’t perform that action at this time.
0 commit comments