Skip to content

Commit

Permalink
Merge branch 'master' into umami-analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
chipzoller authored Sep 29, 2024
2 parents 4e2d3fb + 174a5e6 commit 9fafd5a
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 23 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ These options set global values that some pages or all pages in the site use by
| showRelatedInSidebar | boolean | no |
| footerLogo | string | N/A |
| enableSearch | boolean | N/A |
| blogDir | string | no |

### Page Parameters

Expand Down Expand Up @@ -830,7 +831,18 @@ If you wish use [Utterances](https://github.com/utterance/utterances) comments o

Utterances is loaded in the `comments.html` partial by referring to the `utterances.html` partial. Since `single.html` layout loads comments if comments are enabled, you must ensure *both* the `comments` and `utterances` parameters are configured.

#### Giscus Commenting Support

If you wish to use [giscus](https://giscus.app/) comments on your site, you'll need to perform the following:

* Ensure your repository is [public](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/setting-repository-visibility#making-a-repository-public), otherwise visitors will not be able to view the discussion.
* The [giscus app](https://github.com/apps/giscus) is installed, otherwise visitors will not be able to comment and react.
* The Discussions feature is turned on by [enabling it for your repository](https://docs.github.com/en/github/administering-a-repository/managing-repository-settings/enabling-or-disabling-github-discussions-for-a-repository).
* Comment out the line for `disqusShortname = ""` in the `/config/_default/config.toml` file.
* Set `comments = true` in the `/config/_default/params.toml` file.
* Configure the giscus parameters in the `/config/_default/params.toml` file.

Giscus is loaded in the `comments.html` partial by referring to the `giscus.html` partial. Since `single.html` layout loads comments if comments are enabled, you must ensure *both* the `comments` and `giscus` parameters are configured.


### Math notation
Expand All @@ -849,13 +861,13 @@ mkdir -p layouts/partials && cp themes/clarity/layouts/partials/math.html layout
Then add the corresponding line as its [README](https://github.com/KaTeX/KaTeX/tree/master/contrib/mhchem) suggested (without the `+` sign):

```diff
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css" integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css" integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous">

<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js" integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.js" integrity="sha384-nB0miv6/jRmo5UMMR1wu3Gz6NLsoTkbqJghGIsx//Rlm+ZU03BU6SQNC66uf4l5+" crossorigin="anonymous"></script>

+ <script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/mhchem.min.js" integrity="sha384-5gCAXJ0ZgozlShOzzT0OWArn7yCPGWVIvgo+BAd8NUKbCmulrJiQuCVR9cHlPHeG" crossorigin="anonymous"></script>
+ <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/mhchem.min.js" integrity="sha384-ifpG+NlgMq0kvOSGqGQxW1mJKpjjMDmZdpKGq3tbvD3WPhyshCEEYClriK/wRVU0" crossorigin="anonymous"></script>

<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js" integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous"
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/auto-render.min.js" integrity="sha384-43gviWU0YVjaDtb/GhzOouOXtZMP/7XUzwPTstBeZFe/+rCMvRwr4yROQP43s0Xk" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>
```

Expand Down
3 changes: 2 additions & 1 deletion exampleSite/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
public/
resources/
resources/
.hugo_build.lock
15 changes: 15 additions & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,28 @@ languageMenuName = "🌐"
# Enable or disable comments globally. Default to true.
# comments = false

# Activate meta ld+json for blog
blogDir = "post"

# Enable or disable Utterances (https://github.com/utterance/utterances) Github Issue-Based Commenting
# utterances = true # Run the utterances script in the single.html layout to load https://utteranc.es comments
# utterancesRepo = "GHUsername/Repository.Name" # Utterances is enabled when this param is set
# utterancesLabel = "blog comments ✨💬✨" # The label needs to be manually added to your Github repository issues before configuring here
# utterancesTheme = "github-light" # Default: github-dark
# utterancesIssueTerm = "pathname" # Default: pathname

# Enable or disable Giscus comments globally. Default to false.
# giscus = true
# giscusRepo = "GHUsername/Repository.Name" # Giscus is enabled when this param is set
# giscusRepoId = "RepositoryID" # Required for Giscus to work
# giscusCategory = "Blog"
# giscusCategoryId = "CategoryID" # Required for Giscus to work
# giscusMapping = "pathname" # Default: pathname
# giscusReactionsEnabled = "1" # Default: 1 = true
# giscusTheme = "dark_protanopia" # Default: dark_dimmed
# giscusLang = "en" # Default: en


# Maximum number of recent posts. (default: 8)
# numberOfRecentPosts = 8

Expand Down
15 changes: 7 additions & 8 deletions exampleSite/content/post/math-typesetting.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,26 @@ Mathematical notation in a Hugo project can be enabled by using third party Java

In this example we will be using [KaTeX](https://katex.org/)

- Create a partial under `/layouts/partials/math.html`
- Within this partial reference the [Auto-render Extension](https://katex.org/docs/autorender.html) or host these scripts locally.
- Include the partial in your templates like so:
- Create a partial under `/layouts/partials/hooks/head-end.html`
- Add these lines to the newly created partial:

```bash
{{ if or .Params.math .Site.Params.math }}
{{ partial "math.html" . }}
{{ end }}
```
- To enable KaTex globally set the parameter `math` to `true` in a project's configuration
- To enable KaTex on a per page basis include the parameter `math: true` in content files
- To enable KaTeX globally set the parameter `math` to `true` in a project's configuration
- To enable KaTeX on a per page basis include the parameter `math: true` in content files
**Note:** Use the online reference of [Supported TeX Functions](https://katex.org/docs/supported.html)
{{< math.inline >}}
{{ if or .Page.Params.math .Site.Params.math }}
<!-- KaTeX -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css" integrity="sha384-nB0miv6/jRmo5UMMR1wu3Gz6NLsoTkbqJghGIsx//Rlm+ZU03BU6SQNC66uf4l5+" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.js" integrity="sha384-7zkQWkzuo3B5mTepMUcHkMB5jZaolc2xDwL6VFqjFALcbeS9Ggm/Yr2r3Dy4lfFg" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/auto-render.min.js" integrity="sha384-43gviWU0YVjaDtb/GhzOouOXtZMP/7XUzwPTstBeZFe/+rCMvRwr4yROQP43s0Xk" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
{{ end }}
{{</ math.inline >}}
Expand Down
Empty file removed exampleSite/layouts/.gitkeep
Empty file.
3 changes: 3 additions & 0 deletions exampleSite/layouts/partials/hooks/head-end.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{ if or .Params.math .Site.Params.math }}
{{ partial "math.html" . }}
{{ end }}
3 changes: 3 additions & 0 deletions layouts/partials/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
{{ if .Site.Params.utterances }}
{{ template "partials/utterances.html" . }}
{{ end }}
{{ if .Site.Params.giscus }}
{{ template "partials/giscus.html" . }}
{{ end }}
<!-- add custom comments markup here -->
</div>
4 changes: 2 additions & 2 deletions layouts/partials/figure.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
class="{{ $classes }} image_processed"
width="{{ .Width }}"
height="{{ .Height }}"
src="{{ .RelPermalink }}"
src="{{ .RelPermalink | absURL }}"
{{ else }}
class="{{ $classes }} image_unprocessed"
src="{{ $fileWeb }}"
src="{{ $fileWeb | absURL }}"
{{ end }}
{{ with $cap }}
title="{{ safeHTML $cap }}"
Expand Down
18 changes: 18 additions & 0 deletions layouts/partials/giscus.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{ if .Site.Params.giscus }}
<script src="https://giscus.app/client.js"
data-repo="{{.Site.Params.giscusRepo}}"
data-repo-id="{{.Site.Params.giscusRepoId}}"
data-category="{{.Site.Params.giscusCategory}}"
data-category-id="{{.Site.Params.giscusCategoryId}}"
data-mapping="{{.Site.Params.giscusMapping | default "pathname"}}"
data-strict="0"
data-reactions-enabled="{{.Site.Params.giscusReactionsEnabled | default "1"}}"
data-emit-metadata="0"
data-input-position="top"
data-theme="{{.Site.Params.giscusTheme | default "dark-dimmed"}}"
data-lang="{{.Site.Params.giscusLang | default "en"}}"
data-loading="lazy"
crossorigin="anonymous"
async>
</script>
{{ end }}
6 changes: 3 additions & 3 deletions layouts/partials/math.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css" integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js" integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js" integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css" integrity="sha512-aOFyMMzZF7l7ei3vOKgQiRhZnYqk9YC/uMzl4T0j5N5D3Kul+QAFU8ssENDRMAqr/lxDOjMF69dSYJ8HYqY+WQ==" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.js" integrity="sha512-UPFOadao2nEorjtjl0xUTtN3w20Ja143UPEU6EyJ1mi5MB2bDtMkiWmqGDqi47xNLB5z1dy31GKJDEWhjUJFiQ==" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/auto-render.min.js" integrity="sha512-YJVxTjqttjsU3cSvaTRqsSl0wbRgZUNF+NGGCgto/MUbIvaLdXQzGTCQu4CvyJZbZctgflVB0PXw9LLmTWm5/w==" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
40 changes: 35 additions & 5 deletions layouts/partials/opengraph.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,46 @@
<meta property="og:title" content="{{ $title }}" />
<meta property="og:description" content="{{ $summary }}" />
<meta property="og:image" content="{{ $image }}" />
{{- $keywords := "" }}
{{- $mergedKeywords := slice }}
{{- with $s.keywords }}
{{- $keywords = delimit $s.keywords "," }}
{{- range . }}
{{- $mergedKeywords = $mergedKeywords | append . }}
{{- end }}
{{- end }}
{{- with $p.keywords }}
{{- $keywords = delimit . "," }}
{{- range . }}
{{- $mergedKeywords = $mergedKeywords | append . }}
{{- end }}
{{- end }}
{{- with $s.tags }}
{{- range . }}
{{- $mergedKeywords = $mergedKeywords | append . }}
{{- end }}
{{- end }}
{{- with $keywords }}
<meta name="keywords" content="{{ $keywords }}" />
{{- with $p.tags }}
{{- range . }}
{{- $mergedKeywords = $mergedKeywords | append . }}
{{- end }}
{{- end }}
{{- $mergedKeywordsString := delimit $mergedKeywords "," }}
{{- with $mergedKeywordsString }}
<meta name="keywords" content="{{ $mergedKeywordsString }}" />
{{- end }}
{{- if eq .Section $s.blogDir -}}
{{- $date := ( .Date.Format "2006-02-01") -}}
{{- $date := (time .Date) }}
{{- $lastMod := (time .Lastmod) }}
{{- $categories := slice }}
{{- with $s.categories }}
{{- range . }}
{{- $categories = $categories | append . }}
{{- end }}
{{- end }}
{{- with $p.categories }}
{{- range . }}
{{- $categories = $categories | append . }}
{{- end }}
{{- end }}
<script type="application/ld+json">
{
"@context": "http://schema.org",
Expand All @@ -84,6 +110,10 @@
"url": "{{ $permalink }}",
"datePublished": {{ $date }},
"dateModified": {{ $lastMod }},
"keywords": {{ $mergedKeywords }},
{{- with $categories }}
"articleSection": {{ $categories }},
{{- end }}
"author": {
"@type": "Person",
"name": "{{ $author }}"
Expand Down

0 comments on commit 9fafd5a

Please sign in to comment.