Skip to content

Instantly share code, notes, and snippets.

View jmooring's full-sized avatar

Joe Mooring jmooring

View GitHub Profile

✔️ Build status

With v0.121.2:

                   | EN  
-------------------+-----
  Pages            |  8  
 Paginator pages | 0 
@jmooring
jmooring / math.md
Last active January 22, 2024 19:11
Typesetting example

Inline

// Uses $...$ delimiters
Inline $x = {-b \pm \sqrt{b^2-4ac} \over 2a}$ equation

Inline $x = {-b \pm \sqrt{b^2-4ac} \over 2a}$ equation

Inline over two lines (only the first one works)

@jmooring
jmooring / list.html
Created November 12, 2023 17:38
Example of gist with multiple files
{{ define "main" }}
<h1>{{ .Title }}</h1>
{{ .Content }}
{{ range .Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{ end }}
@jmooring
jmooring / template.html
Created September 2, 2023 02:58
Hugo - Transpile, tree shake, and minify JavaScript
{{ with resources.Get "js/main.js" }}
{{ if eq hugo.Environment "development" }}
{{ with . | js.Build }}
<script src="{{ .RelPermalink }}"></script>
{{ end }}
{{ else }}
{{ $opts := dict "minify" true }}
{{ with . | js.Build $opts | fingerprint }}
<script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
{{ end }}
@jmooring
jmooring / template.html
Last active September 2, 2023 02:51
Hugo - Transpile Sass to CSS
{{ with resources.Get "sass/main.scss" }}
{{ $opts := dict "targetPath" "css/main.css" }}
{{ with . | toCSS $opts }}
{{ if eq hugo.Environment "development" }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{ else }}
{{ with . | minify | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }}
{{ end }}
@jmooring
jmooring / template.html
Created August 3, 2023 22:07
Hugo - Display related content
{{ with site.RegularPages.Related . }}
<p>Related content:</p>
<ul>
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
@jmooring
jmooring / template.html
Last active August 3, 2023 22:09
Hugo - Language switcher
{{ with .AllTranslations }}
<nav class="language-switcher">
{{ range . }}
{{ if eq .Language.Lang $.Language.Lang }}
<a class="active" aria-current="page" href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
{{ else }}
<a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
{{ end }}
{{ end }}
</nav>
@jmooring
jmooring / template.html
Last active August 3, 2023 22:09
Hugo - Display breadcrumb navigation
{{- $currentPage := . }}
{{- with .Ancestors.Reverse }}
<nav class="breadcrumbs">
{{- range $k, $_ := . | append $currentPage }}
{{- if $k }}
<span class="breadcrumb-separator">&raquo;</span>
{{- end }}
{{- if $currentPage.Eq . }}
<a aria-current="page" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
{{- else }}
@jmooring
jmooring / README.md
Last active April 20, 2023 17:06
Ned Flander's Leftorium
@jmooring
jmooring / template.html
Last active August 3, 2023 22:11
Hugo - Display taxonomy terms assigned to a page
{{ with .GetTerms "tags" }}
<ul>
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}