mirror of
https://github.com/gcushen/hugo-academic.git
synced 2025-07-26 19:15:16 +02:00
feat: check that Chroma theme exists
Also renames global Chroma theme variables to: site.Params.features.syntax_highlighter.theme_light site.Params.features.syntax_highlighter.theme_dark
This commit is contained in:
parent
98932fcf96
commit
50de7bd87e
5 changed files with 47 additions and 35 deletions
|
@ -2,5 +2,5 @@
|
|||
|
||||
HUGOxPARAMSxCMSxLOCAL_BACKEND=true \
|
||||
HUGO_MODULE_REPLACEMENTS="github.com/wowchemy/wowchemy-hugo-modules/wowchemy/v5 -> ../../../wowchemy,github.com/wowchemy/wowchemy-hugo-modules/wowchemy-cms/v5 -> ../../../wowchemy-cms" \
|
||||
hugo server --renderStaticToDisk -F --port 80 --bind 0.0.0.0 \
|
||||
hugo server --panicOnWarning --renderStaticToDisk -F --port 80 --bind 0.0.0.0 \
|
||||
--source "starters/$1"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
HUGOxPARAMSxCMSxLOCAL_BACKEND=true \
|
||||
hugo server --renderStaticToDisk -F --port 80 --bind 0.0.0.0 \
|
||||
hugo server --panicOnWarning --renderStaticToDisk -F --port 80 --bind 0.0.0.0 \
|
||||
--source "starters/$1"
|
||||
|
|
|
@ -52,9 +52,6 @@ taxonomies:
|
|||
category: categories
|
||||
markup:
|
||||
merge: _deep
|
||||
highlight:
|
||||
# See https://github.com/wowchemy/wowchemy-hugo-themes/issues/2708
|
||||
codeFences: false
|
||||
related:
|
||||
threshold: 80
|
||||
includeNewer: true
|
||||
|
|
|
@ -37,16 +37,6 @@
|
|||
<script src="https://www.googleoptimize.com/optimize.js?id={{ site.Params.marketing.analytics.google_optimize }}"></script>
|
||||
{{- end -}}
|
||||
|
||||
{{ with site.Params.marketing.verification.google }}
|
||||
<meta name="google-site-verification" content="{{ . }}" />
|
||||
{{- end -}}
|
||||
{{ with site.Params.marketing.verification.baidu }}
|
||||
<meta name="baidu-site-verification" content="{{ . }}" />
|
||||
{{- end -}}
|
||||
{{ with site.Params.marketing.verification.bing }}
|
||||
<meta name="msvalidate.01" content="{{ . }}" />
|
||||
{{- end -}}
|
||||
|
||||
{{/* Attempt to load superuser. */}}
|
||||
{{ $superuser_name := "" }}
|
||||
{{ $superuser_username := "" }}
|
||||
|
@ -147,21 +137,6 @@
|
|||
{{ printf "<link rel=\"stylesheet\" href=\"%s\" integrity=\"%s\" crossorigin=\"anonymous\" media=\"print\" onload=\"this.media='all'\">" (printf $css.fancybox.url $css.fancybox.version) $css.fancybox.sri | safeHTML }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Default to disabling highlighting, but allow the user to override it in .Params or site.Params.
|
||||
Use $scr to store "highlight_enabled", so that we can read it again in footer.html. */}}
|
||||
{{ $scr.Set "highlight_enabled" false }}
|
||||
{{ if isset .Params "highlight" }}
|
||||
{{ $scr.Set "highlight_enabled" .Params.highlight }}
|
||||
{{ else if isset site.Params.features.syntax_highlighter "enable" }}
|
||||
{{ $scr.Set "highlight_enabled" site.Params.features.syntax_highlighter.enable }}
|
||||
{{ end }}
|
||||
{{ $hl_theme_light := site.Params.features.syntax_highlighter.theme_day | default "github-light" }}
|
||||
{{ $hl_theme_dark := site.Params.features.syntax_highlighter.theme_night | default "dracula" }}
|
||||
{{ $hl_theme_light_css := resources.Get (printf "css/libs/chroma/%s.css" $hl_theme_light) | minify }}
|
||||
{{ $hl_theme_dark_css := resources.Get (printf "css/libs/chroma/%s.css" $hl_theme_dark) | minify }}
|
||||
<link rel="stylesheet" href="{{ $hl_theme_light_css.RelPermalink }}" title="hl-light" media="print" onload="this.media='all'" {{ if ne ($scr.Get "light") true }}disabled{{end}}>
|
||||
<link rel="stylesheet" href="{{ $hl_theme_dark_css.RelPermalink }}" title="hl-dark" media="print" onload="this.media='all'" {{ if eq ($scr.Get "light") true }}disabled{{end}}>
|
||||
|
||||
{{/* Maps CSS. */}}
|
||||
{{ $map_provider := lower site.Params.features.map.provider }}
|
||||
{{ if in (slice "mapnik" "mapbox") $map_provider }}
|
||||
|
@ -188,6 +163,7 @@
|
|||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Load WC style */}}
|
||||
{{ $license := printf "/*! Wowchemy v%s | https://wowchemy.com/ */\n" site.Data.wowchemy.version }}
|
||||
{{ $license := $license | printf "%s/*! Copyright 2016-present George Cushen (https://georgecushen.com/) */\n" }}
|
||||
{{ $license := $license | printf "%s/*! License: https://github.com/wowchemy/wowchemy-hugo-themes/blob/main/LICENSE.md */\n" }}
|
||||
|
@ -214,25 +190,53 @@
|
|||
{{- end -}}
|
||||
<link rel="stylesheet" href="{{ $style.RelPermalink }}" />
|
||||
|
||||
{{/* Hugo Chroma Syntax Highlighter Initialization */}}
|
||||
{{/* TODO: optimize to only include the Chroma CSS themes when the page has code blocks. */}}
|
||||
{{ $hl_theme_light := site.Params.features.syntax_highlighter.theme_light | default "github-light" }}
|
||||
{{ $hl_theme_dark := site.Params.features.syntax_highlighter.theme_dark | default "dracula" }}
|
||||
{{ $hl_theme_light_path := printf "css/libs/chroma/%s.css" $hl_theme_light }}
|
||||
{{ $hl_theme_dark_path := printf "css/libs/chroma/%s.css" $hl_theme_dark }}
|
||||
{{ if not (fileExists (printf "assets/%s" $hl_theme_light_path)) | or (not (fileExists (printf "assets/%s" $hl_theme_dark_path))) }}
|
||||
{{ errorf "Hugo Chroma themes %s.css and %s.css not found in `css/libs/chroma/`. See https://gohugo.io/commands/hugo_gen_chromastyles/" $hl_theme_light $hl_theme_dark }}
|
||||
{{ else }}
|
||||
{{ $hl_theme_light_css := resources.Get $hl_theme_light_path | minify }}
|
||||
{{ $hl_theme_dark_css := resources.Get $hl_theme_dark_path | minify }}
|
||||
<link rel="stylesheet" href="{{ $hl_theme_light_css.RelPermalink }}" title="hl-light" media="print" onload="this.media='all'" {{ if ne ($scr.Get "light") true }}disabled{{end}}>
|
||||
<link rel="stylesheet" href="{{ $hl_theme_dark_css.RelPermalink }}" title="hl-dark" media="print" onload="this.media='all'" {{ if eq ($scr.Get "light") true }}disabled{{end}}>
|
||||
{{ end }}
|
||||
|
||||
{{/* Marketing */}}
|
||||
{{ with site.Params.marketing.verification.google }}
|
||||
<meta name="google-site-verification" content="{{ . }}" />
|
||||
{{- end -}}
|
||||
{{ with site.Params.marketing.verification.baidu }}
|
||||
<meta name="baidu-site-verification" content="{{ . }}" />
|
||||
{{- end -}}
|
||||
{{ with site.Params.marketing.verification.bing }}
|
||||
<meta name="msvalidate.01" content="{{ . }}" />
|
||||
{{- end -}}
|
||||
{{ partial "marketing/google_analytics" . }}
|
||||
{{ partial "marketing/google_tag_manager" . }}
|
||||
{{ partial "marketing/microsoft_clarity" . }}
|
||||
{{ partial "marketing/baidu_tongji" . }}
|
||||
|
||||
{{/* Netlify Identity integration. */}}
|
||||
{{ $use_cms := templates.Exists "wowchemycms/single.wowchemycms_config.yml" | default (site.Params.extensions.cms.netlify_cms | default false) }}
|
||||
{{ $use_cms := templates.Exists "wowchemycms/single.wowchemycms_config.yml" | default (site.Params.extensions.cms.enable | default false) }}
|
||||
{{ if .IsHome | and $use_cms }}
|
||||
<script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
|
||||
{{ end }}
|
||||
|
||||
{{/* RSS Feed */}}
|
||||
{{ with .OutputFormats.Get "RSS" }}
|
||||
<link rel="alternate" href="{{ .RelPermalink }}" type="application/rss+xml" title="{{ site.Title }}" />
|
||||
{{ end }}
|
||||
|
||||
{{/* Progressive Web App (PWA) Manifest */}}
|
||||
{{ with site.Home.OutputFormats.Get "WebAppManifest" }}
|
||||
<link rel="manifest" href="{{ .RelPermalink }}" />
|
||||
{{ end }}
|
||||
|
||||
{{/* Progressive Web App (PWA) Icon */}}
|
||||
<link rel="icon" type="image/png" href="{{ (partial "functions/get_icon" 32).RelPermalink }}" />
|
||||
<link rel="apple-touch-icon" type="image/png" href="{{ (partial "functions/get_icon" 180).RelPermalink }}" />
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<html lang="{{ site.LanguageCode | default "en-us" }}">
|
||||
<head>
|
||||
|
||||
{{ $cdn_url_reveal := "https://cdn.jsdelivr.net/npm/reveal.js@4.2.1" }}
|
||||
{{ $cdn_url_reveal := "https://cdn.jsdelivr.net/npm/reveal.js@4.3.1" }}
|
||||
{{ $js := site.Data.assets.js }}
|
||||
{{ $css := site.Data.assets.css }}
|
||||
|
||||
|
@ -22,14 +22,22 @@
|
|||
|
||||
<title>{{ .Title }} | {{ site.Title }}</title>
|
||||
|
||||
{{/* Load Reveal CSS */}}
|
||||
<link rel="stylesheet" href="{{ $cdn_url_reveal }}/dist/reveal.min.css">
|
||||
{{- $theme := $.Param "slides.theme" | default "black" -}}
|
||||
<link rel="stylesheet" href="{{ $cdn_url_reveal }}/dist/theme/{{ $theme }}.min.css">
|
||||
|
||||
{{/* Hugo Chroma Syntax Highlighter Initialization */}}
|
||||
{{ $hl_theme := $.Param "slides.highlight_style" | default "dracula" }}
|
||||
{{ $hl_theme_css := resources.Get (printf "css/libs/chroma/%s.css" $hl_theme) | minify }}
|
||||
<link rel="stylesheet" href="{{ $hl_theme_css.RelPermalink }}">
|
||||
{{ $hl_theme_path := printf "css/libs/chroma/%s.css" $hl_theme }}
|
||||
{{ if not (fileExists (printf "assets/%s" $hl_theme_path)) }}
|
||||
{{ errorf "Hugo Chroma themes %s.css not found in `css/libs/chroma/`. See https://gohugo.io/commands/hugo_gen_chromastyles/" $hl_theme }}
|
||||
{{ else }}
|
||||
{{ $hl_theme_css := resources.Get $hl_theme_path | minify }}
|
||||
<link rel="stylesheet" href="{{ $hl_theme_css.RelPermalink }}">
|
||||
{{ end }}
|
||||
|
||||
{{/* Load any Reveal CSS customizations */}}
|
||||
{{ $css_custom := resources.Get "css/reveal_custom.css" }}
|
||||
{{ $style := slice $css_custom | resources.Concat "css/reveal_custom.css" | resources.Minify }}
|
||||
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
|
||||
|
@ -38,6 +46,7 @@
|
|||
|
||||
{{ block "main" . }}{{ end }}
|
||||
|
||||
{{/* Load Reveal and built-in plugins. */}}
|
||||
<script src="{{ $cdn_url_reveal }}/dist/reveal.min.js" crossorigin="anonymous"></script>
|
||||
<script src="{{ $cdn_url_reveal }}/plugin/markdown/markdown.min.js" crossorigin="anonymous"></script>
|
||||
<script src="{{ $cdn_url_reveal }}/plugin/notes/notes.min.js" crossorigin="anonymous"></script>
|
||||
|
@ -45,17 +54,19 @@
|
|||
<script src="{{ $cdn_url_reveal }}/plugin/math/math.min.js" crossorigin="anonymous"></script>
|
||||
<script src="{{ $cdn_url_reveal }}/plugin/zoom/zoom.min.js" crossorigin="anonymous"></script>
|
||||
|
||||
{{/* Third-party Reveal plugins. */}}
|
||||
{{/* Load third-party Reveal plugins. */}}
|
||||
{{ if $.Param "slides.reveal_options.menu_enabled" | default true}}
|
||||
<script src="https://cdn.jsdelivr.net/npm/reveal.js-menu@2.1.0/plugin.js" integrity="sha256-M6JwAjnRAWmi+sbXURR/yAhWZKYhAw7YXnnLvIxrdGs=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/reveal.js-menu@2.1.0/menu.js" integrity="sha256-l14dklFcW5mWar6w/9KaW0fWVerf3mYr7Wt0+rXzFAA=" crossorigin="anonymous"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/reveal.js-menu@2.1.0/menu.css" integrity="sha256-0fU8HKLaTjgzfaV9CgSqbsN8ilA3zo6zK1M6rlgULd8=" crossorigin="anonymous">
|
||||
{{ end }}
|
||||
|
||||
{{/* Load Mermaid. */}}
|
||||
{{ if $.Param "slides.diagram" | default false}}
|
||||
{{ printf "<script src=\"%s\" integrity=\"%s\" crossorigin=\"anonymous\" title=\"mermaid\"></script>" (printf $js.mermaid.url $js.mermaid.version) $js.mermaid.sri | safeHTML }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Initialize slides. */}}
|
||||
{{ $slidejs := resources.Get "js/wowchemy-slides.js" | js.Build (dict "params" (dict "slides" $.Params.slides )) }}
|
||||
<script src="{{ $slidejs.RelPermalink }}"></script>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue