1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-27 14:12:09 +00:00

Only load syntax highlighting CSS if necessary..

Pages without highlighted code blocks don't need to load syntax.css; for
those that do, simply declare "highlight: true" in the front matter to
load the stylesheet separately.
This commit is contained in:
rohan kumar 2020-11-28 11:11:04 -08:00
parent 6fba7dbc9a
commit 1e44855647
No known key found for this signature in database
GPG key ID: 1E892DB2A5F84479
2 changed files with 5 additions and 10 deletions

View file

@ -14,7 +14,7 @@ description = "Seirdy's personal website"
src = "https://sr.ht/~seirdy/seirdy.one"
copyright = "Copyright © 2020 Rohan Kumar"
dark = "auto"
highlight = true
highlight = false
[author]
name = "Rohan Kumar"

View file

@ -10,24 +10,19 @@
<meta name="robots" content="noindex">
{{ end -}}
<link rel="canonical" href="https://seirdy.one{{ .RelPermalink }}"/>
{{ $resources := slice -}}
{{ $resources = $resources | append (resources.Get "/css/main.css") -}}
{{ $resources = $resources | append (resources.Get "/css/narrow.css") -}}
{{ $dark := .Site.Params.dark | default "auto" -}}
{{ if not (eq $dark "off") -}}
{{ $resources = $resources | append (resources.Get "css/dark.css" | resources.ExecuteAsTemplate "dark.css" .) -}}
{{ end -}}
{{ if .Site.Params.highlight -}}
{{ $resources = $resources | append (resources.Get "css/syntax.css") -}}
{{ end -}}
{{ $css := $resources | resources.Concat "css/style.css" | minify }}
{{ printf `<link rel="stylesheet" href="%s">` $css.RelPermalink | safeHTML }}
{{ if .Params.highlight -}}
{{ printf `<link rel="stylesheet" href="/css/syntax.css">` | safeHTML }}
{{ end -}}
<title>{{ .Title }}</title>
</head>