Skip to content

Commit

Permalink
Close Issue #33
Browse files Browse the repository at this point in the history
  • Loading branch information
1bl4z3r committed Oct 28, 2023
1 parent 0b24b5f commit 39a5083
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 78 deletions.
27 changes: 14 additions & 13 deletions content/posts/explaining-configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ tags:
scrolltotop : true
toc : true
ShowLastmod : true
Lastmod : 2023-10-25T13:30:30+05:30
Lastmod : 2023-10-28T20:30:30+05:30
---

## Configuation in `hugo.toml`

`hugo.toml` represents Global configuration for Hermit - V2. It is indicative on the changes to make the theme tailored to your personal preferences.

`baseURL` : The absolute URL (protocol, host, path, and trailing slash) of your published site. Required :- YES
- `languageCode` - A language tag as defined by RFC 5646. This value is used to populate:
`baseURL` : The absolute URL (protocol, host, path, and trailing slash) of your published site.
- `languageCode` : A language tag as defined by RFC 5646. This value is used to populate:
- The <language> element in the internal RSS template
- The lang attribute of the <html> element in the internal alias template
- `title` - Title of the Site
- `enableGitInfo` - Enable .GitInfo object for each page (if the Hugo site is versioned by Git). This will then update the Lastmod parameter for each page using the last git commit date for that content file.
> Sideeffect : Affects `.Lastmod` parameter in Pages
- `hasCJKLanguage` - If Chinese/Japanese/Korean is your main content language, enable this to make wordCount works right.
- `pygmentsCodefences` -Set to true to enable syntax highlighting in code fences with a language tag in markdown.
- `pygmentsUseClasses` - Set to `true` to use CSS classes to format your highlighted code.
- `rssLimit` - Maximum number of items in the RSS feed.
- `copyright` - This message is only used by the RSS template.
- `enableGitInfo` : Enable .GitInfo object for each page (if the Hugo site is versioned by Git). This will then update the Lastmod parameter for each page using the last git commit date for that content file.
> Side-effect : Affects `.Lastmod` parameter in Pages
- `hasCJKLanguage` : If Chinese/Japanese/Korean is your main content language, enable this to make wordCount works right.
- `pygmentsCodefences` : Set to true to enable syntax highlighting in code fences with a language tag in markdown.
- `pygmentsUseClasses` : Set to `true` to use CSS classes to format your highlighted code.
- `rssLimit` : Maximum number of items in the RSS feed.
- `copyright` : This message is only used by the RSS template.
- `enableEmoji` : Enables shorthand emojis in content files. [Info](https://gohugo.io/functions/emojify/)
- `googleAnalytics` : Enter Google Analytics UA code to invoke inbuilt Google Analytics.
- `disqusShortname` : To enable Disqus.
Expand All @@ -53,10 +53,11 @@ Lastmod : 2023-10-25T13:30:30+05:30
- `global_mathjax` : Enable global_mathjax to true, if you want MathJax support sitewide (if you have technical page)
- `readTime` : Toggle Reading time for articles.
- `readTimeSeparator` : Specifies Separator between wordCount and readTime.
- `legacyLayout` : Enable legacy layout (where post info is below content)
- `[params.social]` Refer [README](https://github.com/1bl4z3r/hermit-V2#social-icons)
- `name` : Name of the social page.
- `url` : URL of your account.
- `[menu]` - Display menu items in Homepage as well as in menubar. To make more menu items, use [[menu.main]]
- `[menu]` : Display menu items in Homepage as well as in menubar. To make more menu items, use [[menu.main]]

## Configuration in page Frontmatter

Expand All @@ -78,7 +79,7 @@ Lastmod : 2023-10-25T13:30:30+05:30
- `toc` : Enables Table of Contents.
- `custom_css` : Allows to supply custom CSS by placing the css files in `/static/css/`. CSS will be invoked for that page only.
- `custom_js` : Allows to supply custom CSS by placing the css files in `/static/js/`. JS will be invoked for that page only.
- `ShowLastmod` :This enables Last modification date of the given Page.
- `ShowLastmod` : This enables Last modification date of the given Page.
- `Lastmod` : REQUIRED (If `ShowLastmod=true`). Enter Last modified date of the Page.

## Special Caveats
Expand Down
3 changes: 2 additions & 1 deletion hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ enableEmoji = true
scrollToTop = true
global_mathjax = false
readTime = true
readTimeSeparator = "\u002F||\u005C Reading Time:"
readTimeSeparator = "\u2026 \u23F2 Reading Time:"
# legacyLayout = false

[[params.social]]
name = "twitter"
Expand Down
42 changes: 19 additions & 23 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,25 @@
<html lang="{{.Site.LanguageCode}}">

<head>
{{- partial "analytics.html" . }}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
{{- with .Site.Params.themeColor }}
<meta name="theme-color" content="{{.}}">
<meta name="msapplication-TileColor" content="{{.}}">
{{- end }}
{{- partial "structured-data.html" . }}
{{- partial "favicons.html" }}
<title>{{.Title}}</title>
{{ range .AlternativeOutputFormats -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Title | safeHTML }}
{{ end -}}
{{ $style := resources.Get "scss/style.scss" | resources.ExecuteAsTemplate "css/style.css" . | toCSS | minify | fingerprint -}}
<link rel="stylesheet" href="{{ $style.Permalink }}" {{ printf "integrity=%q" $style.Data.Integrity | safeHTMLAttr }} crossorigin="anonymous">
{{- range .Params.custom_css }}
<link rel="stylesheet" href="{{ . | absURL }}">
{{- end }}
{{- block "head" . -}}{{- end }}
{{- if templates.Exists "partials/extra-head.html" -}}
{{ partial "extra-head.html" . }}
{{- end }}
{{- partial "analytics.html" . }}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
{{- with .Site.Params.themeColor }}
<meta name="theme-color" content="{{.}}">
<meta name="msapplication-TileColor" content="{{.}}">
{{- end -}}
{{- partial "structured-data.html" . -}}
{{- partial "favicons.html" -}}
<title>{{.Title}}</title>
{{ range .AlternativeOutputFormats -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Title | safeHTML }}
{{ end -}}
{{ $style := resources.Get "scss/style.scss" | resources.ExecuteAsTemplate "css/style.css" . | toCSS | minify | fingerprint -}}
<link rel="stylesheet" href="{{ $style.Permalink }}" {{ printf "integrity=%q" $style.Data.Integrity | safeHTMLAttr }} crossorigin="anonymous">
{{- range .Params.custom_css -}}<link rel="stylesheet" href="{{ . | absURL }}">{{- end -}}
{{- block "head" . -}}{{- end }}
{{- if templates.Exists "partials/extra-head.html" -}}{{ partial "extra-head.html" . }}{{- end }}
</head>

<body id="page">
Expand Down
12 changes: 6 additions & 6 deletions layouts/partials/favicons.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<link rel="apple-touch-icon" sizes="180x180" href="{{"apple-touch-icon.png" | relURL}}">
<link rel="icon" type="image/png" sizes="32x32" href="{{"favicon-32x32.png" | relURL}}">
<link rel="icon" type="image/png" sizes="16x16" href="{{"favicon-16x16.png" | relURL}}">
<link rel="manifest" href="{{"site.webmanifest" | relURL}}">
<link rel="mask-icon" href="{{"safari-pinned-tab.svg" | relURL}}" color="{{.Site.Params.themeColor}}">
<link rel="shortcut icon" href="{{"favicon.ico" | relURL}}">
<link rel="apple-touch-icon" sizes="180x180" href="{{"apple-touch-icon.png" | relURL}}">
<link rel="icon" type="image/png" sizes="32x32" href="{{"favicon-32x32.png" | relURL}}">
<link rel="icon" type="image/png" sizes="16x16" href="{{"favicon-16x16.png" | relURL}}">
<link rel="manifest" href="{{"site.webmanifest" | relURL}}">
<link rel="mask-icon" href="{{"safari-pinned-tab.svg" | relURL}}" color="{{.Site.Params.themeColor}}">
<link rel="shortcut icon" href="{{"favicon.ico" | relURL}}">
20 changes: 20 additions & 0 deletions layouts/partials/posts_single_info.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{- with .Params.description }}<p>{{.}}</p>{{- end }}
{{- if and .Params.author .Params.authorLink}}{{ $relreflink := relref . .Params.authorLink }}<p>{{ partial "svg.html" (dict "context" . "name" "author") }}<a href="{{ $relreflink }}" target="_blank">{{ .Params.author }}</a></p>
{{- else if .Params.author }}{{ $relreflink := relref . .Site.Author.about }}<p>{{ partial "svg.html" (dict "context" . "name" "author") }}<a href="{{ $relreflink }}" target="_blank">{{ .Params.author }}</a></p>
{{- else }}{{ $relreflink := relref . .Site.Author.about }}<p>{{ partial "svg.html" (dict "context" . "name" "author") }}<a href="{{ $relreflink }}" target="_blank">{{ .Site.Author.name }}</a></p>
{{- end }}
{{- with .Params.tags }}
<p>{{- partial "svg.html" (dict "context" . "name" "posts_single_tags") -}}{{- range . -}}<span class="tag"><a href="{{ "tags/" | absLangURL }}{{ . | urlize }}">{{.}}</a></span>{{- end }}</p>
{{- end }}
<p>{{- partial "svg.html" (dict "context" . "name" "posts_single_wordcount") }}{{ i18n "wordCount" . -}} {{- partial "readTime.html" . -}}</p>
<p>{{- partial "svg.html" (dict "context" . "name" "posts_single_date") }}{{ dateFormat .Site.Params.dateformNumTime .Date.Local -}}
{{- if and (not (eq .Page.Params.ShowLastmod nil)) (.Page.Params.ShowLastmod) -}}
{{- if and .GitInfo .Site.Params.gitUrl -}}
[{{- partial "svg.html" (dict "context" . "name" "posts_single_git_commit") -}}<a href="{{ .Site.Params.gitUrl -}}{{ .GitInfo.Hash }}" target="_blank" rel="noopener">{{ .GitInfo.AbbreviatedHash -}}</a> @ {{ dateFormat .Site.Params.dateformNum .GitInfo.AuthorDate.Local -}}]
{{- else if not (eq .Lastmod .Date ) -}}
&nbsp;[Modified : {{ dateFormat .Site.Params.dateformNumTime .Lastmod.Local -}}]
{{- else -}}
{{ errorf "Lastmod is not found in Page Frontmatter or Lastmod is same as Date" }}
{{- end -}}
{{- end -}}
</p>
2 changes: 2 additions & 0 deletions layouts/partials/svg.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-calendar"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>
{{- else if (eq .name "posts_single_git_commit") -}}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-git-commit"><circle cx="12" cy="12" r="4"></circle><line x1="1.05" y1="12" x2="7" y2="12"></line><line x1="17.01" y1="12" x2="22.96" y2="12"></line></svg>
{{- else if (eq .name "posts_single_tags") -}}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-tag meta-icon"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"></path><line x1="7" y1="7" x2="7" y2="7"></line></svg>
{{- else -}}
<svg xmlns="http://www.w3.org/2000/svg" class="feather feather-link" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
{{- end -}}
53 changes: 18 additions & 35 deletions layouts/posts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,29 @@
<div class="bg-img"></div>
{{- end }}
<main class="site-main section-inner animated fadeIn faster">
{{- if and (not (eq .Site.Params.legacyLayout nil)) (.Site.Params.legacyLayout) -}}
<article class="thin">
<header class="post-header">
<div class="post-meta"><span>{{ .Date.Format .Site.Params.dateform }}</span></div>
<h1>{{ .Title }}</h1>
</header>
<div class="post-info">
{{- with .Params.description }}
<p>{{.}}</p>
{{- end }}

{{- if and .Params.author .Params.authorLink}}
{{ $relreflink := relref . .Params.authorLink }}
<p>{{ partial "svg.html" (dict "context" . "name" "author") }}<a href="{{ $relreflink }}" target="_blank">{{ .Params.author }}</a></p>
{{- else if .Params.author }}
{{ $relreflink := relref . .Site.Author.about }}
<p>{{ partial "svg.html" (dict "context" . "name" "author") }}<a href="{{ $relreflink }}" target="_blank">{{ .Params.author }}</a></p>
{{- else }}
{{ $relreflink := relref . .Site.Author.about }}
<p>{{ partial "svg.html" (dict "context" . "name" "author") }}<a href="{{ $relreflink }}" target="_blank">{{ .Site.Author.name }}</a></p>
{{- end }}
{{- with .Params.tags }}
<p>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-tag meta-icon"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"></path><line x1="7" y1="7" x2="7" y2="7"></line></svg>
{{- range . -}}
<span class="tag"><a href="{{ "tags/" | absLangURL }}{{ . | urlize }}">{{.}}</a></span>
{{- end }}
</p>
{{- end }}
<p>{{- partial "svg.html" (dict "context" . "name" "posts_single_wordcount") }}{{ i18n "wordCount" . -}} {{- partial "readTime.html" . -}}</p>
<p>{{- partial "svg.html" (dict "context" . "name" "posts_single_date") }}{{ dateFormat .Site.Params.dateformNumTime .Date.Local -}}
{{- if and (not (eq .Page.Params.ShowLastmod nil)) (.Page.Params.ShowLastmod) -}}
{{- if and .GitInfo .Site.Params.gitUrl -}}
[{{- partial "svg.html" (dict "context" . "name" "posts_single_git_commit") -}}<a href="{{ .Site.Params.gitUrl -}}{{ .GitInfo.Hash }}" target="_blank" rel="noopener">{{ .GitInfo.AbbreviatedHash -}}</a> @ {{ dateFormat .Site.Params.dateformNum .GitInfo.AuthorDate.Local -}}]
{{- else if not (eq .Lastmod .Date ) -}}
&nbsp;[Modified : {{ dateFormat .Site.Params.dateformNumTime .Lastmod.Local -}}]
{{- else -}}
{{ errorf "Lastmod is not found in Page Frontmatter or Lastmod is same as Date" }}
{{- end -}}
{{- end -}}
</p>
<div class="content">
{{ .Content | replaceRE "(<h[1-6] id=\"([^\"]+)\".+)(</h[1-6]+>)" `${1}<a href="#${2}" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path><line x1="8" y1="12" x2="16" y2="12"></line></svg></a>${3}` | safeHTML }}
</div>
{{- if .Site.Params.relatedPosts }}
{{- partial "related-posts.html" . -}}
{{- end }}
<hr class="art-end">
<footer class="post-info">{{- partial "posts_single_info.html" . -}}</footer>
<hr class="post-end">
</article>
{{- else -}}
<article class="thin">
<header class="post-header">
<div class="post-meta"><span>{{ .Date.Format .Site.Params.dateform }}</span></div>
<h1>{{ .Title }}</h1>
</header>
<div class="post-info">{{- partial "posts_single_info.html" . -}}</div>
<hr class="post-end">
<div class="content">
{{ .Content | replaceRE "(<h[1-6] id=\"([^\"]+)\".+)(</h[1-6]+>)" `${1}<a href="#${2}" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path><line x1="8" y1="12" x2="16" y2="12"></line></svg></a>${3}` | safeHTML }}
Expand All @@ -67,6 +49,7 @@ <h1>{{ .Title }}</h1>
{{- end }}
<hr class="art-end">
</article>
{{- end -}}
{{- if .Params.toc }}
<aside id="toc">
<div class="toc-title">{{ i18n "tableOfContents" }}</div>
Expand Down

0 comments on commit 39a5083

Please sign in to comment.