1
0
mirror of https://github.com/alanorth/hugo-theme-bootstrap4-blog.git synced 2024-11-16 09:17:03 +01:00
hugo-theme-bootstrap4-blog/layouts/_default/baseof.html
Alan Orth 3ab60bddea
Use Font Awesome SVGs via JavaScript
This is a bit of "one step forward, two steps back" in that we are
now using the much more lean SVG icons—and only the ones we are ac
tually using—instead of having to download the two ~70KiB web font
files, but it means we need to use JavaScript.

This approache was inspired by the work @xekon did in #127.

See: https://fontawesome.com/how-to-use/on-the-web/advanced/svg-javascript-core
See: https://github.com/alanorth/hugo-theme-bootstrap4-blog/pull/127
2020-01-27 18:17:35 +02:00

108 lines
3.8 KiB
HTML

<!DOCTYPE html>
<html lang="{{ .Lang }}" {{ if or (eq .Lang "ar") (eq .Lang "fa") }}dir="rtl"{{ end }}>
<head>
{{ partial "head-meta.html" . }}
{{ block "schema-dot-org" . }}
<!-- schema.org metadata differs for Nodes and Pages -->
{{ end }}
<link rel="canonical" href="{{ .Permalink }}">
<title>{{ block "title" . }}{{ .Site.Title }}{{ end }}</title>
{{ if or (eq .Lang "ar") (eq .Lang "fa") }}
{{ "<!-- RTL -->" | safeHTML }}
{{ $styleRtl := resources.Get "css/style.rtl.css" | resources.Fingerprint }}
<link href="{{ $styleRtl.Permalink }}" rel="stylesheet"{{ if not .Site.Params.disable_sri }} integrity="{{ $styleRtl.Data.Integrity }}" crossorigin="anonymous"{{ end }}>
{{ else }}
{{ "<!-- combined, minified CSS -->" | safeHTML }}
{{ $style := resources.Get "css/style.css" | resources.Fingerprint }}
<link href="{{ $style.Permalink }}" rel="stylesheet"{{ if not .Site.Params.disable_sri }} integrity="{{ $style.Data.Integrity }}" crossorigin="anonymous"{{ end }}>
{{ end }}
{{ "<!-- minified Font Awesome for SVG icons -->" | safeHTML }}
{{ $fontawesome := resources.Get "js/fontawesome.min.js" | resources.Fingerprint }}
<script defer src="{{ $fontawesome.Permalink }}" integrity="{{ $fontawesome.Data.Integrity }}" crossorigin="anonymous"></script>
{{ "<!-- RSS 2.0 feed -->" | safeHTML }}
{{ with .OutputFormats.Get "rss" -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}
{{ template "_internal/google_analytics_async.html" . }}
{{ if .Site.Params.cookie_consent_info_url }}
{{ partial "cookie-consent.html" . }}
{{ end }}
{{ partial "head-custom.html" . }}
</head>
<body>
{{ block "masthead" . }}
<div class="blog-masthead">
<div class="container">
<nav class="nav blog-nav">
<a class="nav-link {{ if .IsHome }}active{{ end }}" href="{{ .Site.BaseURL | absLangURL }}">{{ i18n "home" }}</a>
{{- $currentPage := . -}}
{{ range .Site.Menus.navbar }}
{{ $menuURL := .URL | absLangURL }}
<a class="nav-link{{ if or ($currentPage.IsMenuCurrent "navbar" .) ($currentPage.HasMenuCurrent "navbar" .) }} active{{end}}" href="{{ .URL }}" title="{{ .Title }}">{{ .Name }}</a>
{{ end }}
</nav>
</div>
</div>
{{ end }}
{{ block "header" . }}
{{ if (ne .Site.Params.header_visible false) }}
<header class="blog-header">
<div class="container">
<h1 class="blog-title" dir="auto"><a href="{{ .Site.BaseURL | absURL }}" rel="home">{{ .Site.Title | safeHTML }}</a></h1>
{{ if .Site.Params.description }}<p class="lead blog-description" dir="auto">{{ .Site.Params.description | markdownify }}</p>{{ end }}
</div>
</header>
{{ end }}
{{ end }}
{{ block "body" . }}
<div class="container">
<div class="row">
<div class="col-sm-8 blog-main">
{{ block "main" . }}
<!-- The part of the page that begins to differ between templates -->
{{ end }}
</div> {{ "<!-- /.blog-main -->" | safeHTML }}
{{ partial "sidebar.html" . }}
</div> {{ "<!-- /.row -->" | safeHTML }}
</div> {{ "<!-- /.container -->" | safeHTML }}
{{ end }}
{{ block "footer" . }}
<footer class="blog-footer">
<p dir="auto">
{{ if .Site.Copyright }}
{{ .Site.Copyright | markdownify }}
{{ else }}
Blog template created by <a href="https://twitter.com/mdo">@mdo</a>, ported to Hugo by <a href='https://twitter.com/mralanorth'>@mralanorth</a>.
{{ end }}
</p>
<p>
<a href="#">{{ i18n "backToTop" }}</a>
</p>
</footer>
{{ end }}
</body>
</html>
{{- /* vim: set ts=2 sw=2 et: */}}