feat: new partials: comments_counter and single_base

This commit is contained in:
Mirus 2024-07-29 10:47:00 +03:00
parent 9f17b5fa0d
commit a85b82b722
5 changed files with 120 additions and 8 deletions

View File

@ -18,7 +18,7 @@ So, welcome aboard! I'm excited to have you join us on this journey as we shape
----
![Terminal](https://github.com/mirus-ua/hugo-theme-re-terminal/blob/master/images/screenshot.png?raw=true)
![Terminal](https://github.com/mirus-ua/hugo-theme-re-terminal/blob/main/images/screenshot.png?raw=true)
~~### DEMO - https://hugo-terminal.now.sh/~~ outdated
@ -282,13 +282,17 @@ to `config.toml` file in your Hugo root directory and change params fields. In c
## Post archetype
See the default `post` file params supported by the theme — https://github.com/mirus-ua/hugo-theme-re-terminal/blob/master/archetypes/posts.md
See the default `post` file params supported by the theme — https://github.com/mirus-ua/hugo-theme-re-terminal/blob/main/archetypes/posts.md
## Add-ons
- **Comments** — for adding comments to your blog posts please take a look at `layouts/partials/comments.html` https://github.com/mirus-ua/hugo-theme-re-terminal/blob/master/layouts/partials/comments.html.
- **Extended Head** — please take a look at `layouts/partials/extended_head.html` https://github.com/mirus-ua/hugo-theme-re-terminal/blob/master/layouts/partials/extended_head.html
- **Extended Footer** — please take a look at `layouts/partials/extended_footer.html` https://github.com/mirus-ua/hugo-theme-re-terminal/blob/master/layouts/partials/extended_footer.html
- **Comments** — for adding comments to your blog posts please take a look at `layouts/partials/comments.html` https://github.com/mirus-ua/hugo-theme-re-terminal/blob/main/layouts/partials/comments.html.
- **Comments counter** — for adding comments counter to your blog posts please take a look at `layouts/partials/comments_counter.html` https://github.com/mirus-ua/hugo-theme-re-terminal/blob/main/layouts/partials/comments_counter.html.
- **Extended Head** — please take a look at `layouts/partials/extended_head.html` https://github.com/mirus-ua/hugo-theme-re-terminal/blob/main/layouts/partials/extended_head.html
- **Extended Footer** — please take a look at `layouts/partials/extended_footer.html` https://github.com/mirus-ua/hugo-theme-re-terminal/blob/main/layouts/partials/extended_footer.html
### Low-level add-ons
- **Post base** — Renders bare minimum of posts' content. For motivation and details take a look at https://github.com/mirus-ua/hugo-theme-re-terminal/blob/main/layouts/partials/extended_footer.html
## How to edit the theme <a id="how-to-edit" />
@ -319,7 +323,7 @@ Sounds OK? Cool, let's rock! 🤘
## Terminal theme user?
I'd be happy to know more about you and what you are doing. If you want to share it, please make a contribution and [add your site to the list](https://github.com/mirus-ua/hugo-theme-re-terminal/blob/master/USERS.md)! 🤗
I'd be happy to know more about you and what you are doing. If you want to share it, please make a contribution and [add your site to the list](https://github.com/mirus-ua/hugo-theme-re-terminal/blob/main/USERS.md)! 🤗
## License
@ -328,4 +332,4 @@ Copyright © 2019-2022 Radosław Kozieł ([@panr](https://twitter.com/panr))
Copyright © 2024-now Mirus
The theme is released under the MIT License. Check the [original theme license](https://github.com/mirus-ua/hugo-theme-re-terminal/blob/master/LICENSE.md) for additional licensing information.
The theme is released under the MIT License. Check the [original theme license](https://github.com/mirus-ua/hugo-theme-re-terminal/blob/main/LICENSE.md) for additional licensing information.

View File

@ -5,6 +5,10 @@
<title>{{ if .IsHome }}{{ $.Site.Title }}{{ else }}{{ .Title }} :: {{ $.Site.Title }}{{ end }}</title>
{{ end }}
{{ partial "head.html" . }}
{{ block "head" . }}{{""}}{{ end }}
</head>
<body class="{{- ( or .Params.color $.Site.Params.ThemeColor ) -}}">
{{ $container := cond ($.Site.Params.FullWidthTheme | default false) "container full" (cond ($.Site.Params.CenterTheme | default false) "container center" "container") }}

View File

@ -0,0 +1,17 @@
<!--
To add comments section, please create `layouts/partials/comments_counter.html` in your
Hugo directory and insert:
you can use the snippet bellow to add disqus comments counter to your posts
<span>
<a class="disqus_comments" href="{{ .Permalink }}#disqus_thread">
<span
class="disqus-comment-count"
data-disqus-url="{{ with .Params.disqus_url }}{{ . }}{{ else }}{{ .Permalink }}{{ end }}">O {{ $.Site.Params.comments | default "comments" }}</span>
{{ .Site.Params.noCounter }}
</a>
</span>
or whatever comment engine you want -> https://gohugo.io/content-management/comments/#readout
-->

View File

@ -0,0 +1,87 @@
<!--
The single_basic.html partial layout in Jekyll allows you to create custom HTML, CSS, and JavaScript
for individual pages on your site without modifying the default layout.
This makes it easier to maintain consistency across your site
while still allowing you to customize individual pages as needed.
It also allows you to reuse the same code for multiple pages,
making it a useful tool for creating custom widgets or demos that can be added to multiple pages on your site.
Take a look at https://gohugo.io/methods/page/layout/
# An example of `layouts/posts/foo.html`
# Then you can use it as layout = "foo" in .MD files' meta in your `content/posts` folder
{{ define "head" }}
###
HERE INSERT ANY CUSTOM <script/> or <style/>
###
{{ end }}{{ define "main" }}
<div class="post">
# The post itself
{{ partial "single_basic.html" . }}
###
HERE INSERT ANY CUSTOM HTML
###
# Comments block
{{ if eq .Type $.Site.Params.contentTypeName }} {{ partial
"posts_pagination.html" . }} {{ end }} {{ if not (.Params.hideComments |
default false) }} {{ partial "comments.html" . }} {{ end }}
</div>
{{ end }}
-->
<h1 class="post-title">
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>
<div class="post-meta">
{{ if .Params.Date }}
<span class="post-date">
{{ .Date.Format "2006-01-02" }}
{{ if $.Site.Params.showLastUpdated }}
[{{or $.Site.Params.updatedDatePrefix "Updated"}}: {{ .Lastmod.Format "2006-01-02" }}]
{{ end }}
</span>
{{ end }}
{{ with .Params }}
<span class="post-author">
{{ if .AuthorTwitter }}
<a href="https://x.com/@{{ .AuthorTwitter }}" target="_blank">{{ .Author }}</a>
{{ else }}
{{ .Author }}
{{ end }}
</span>
{{ end }}
<!-- comments counter -->
{{ partial "comments_counter.html" . }}
{{ if and (.Param "readingTime") (eq (.Param "readingTime") true) }}
<span class="post-reading-time"> {{ .ReadingTime }} {{ $.Site.Params.minuteReadingTime | default "min read" }} ({{ .WordCount }} {{ $.Site.Params.words | default "words" }})</span>
{{ end }}
</div>
{{ if .Params.tags }}
<span class="post-tags">
{{ range .Params.tags }}
#<a href="{{ (urlize (printf "tags/%s/" .)) | absLangURL }}">{{ . }}</a>&nbsp;
{{ end }}
</span>
{{ end }}
{{ partial "cover.html" . }}
{{ if (.Params.Toc | default .Site.Params.Toc) }}
<div class="table-of-contents">
<h2>
{{ (.Params.TocTitle | default .Site.Params.TocTitle) | default "Зміст" }}
</h2>
{{ .TableOfContents }}
</div>
{{ end }}
<div class="post-content">
{{- with .Content -}}
<div>
{{ . | replaceRE "(<h[1-9] id=\"([^\"]+)\".+)(</h[1-9]+>)" `${1}<a href="#${2}" class="hanchor" ariaLabel="Anchor">&#8983;</a> ${3}` | safeHTML }}
</div>
{{- end -}}
</div>

View File

@ -1,6 +1,6 @@
name = "re-terminal"
license = "MIT"
licenselink = "https://github.com/mirus-ua/hugo-theme-re-terminal/blob/master/LICENSE.md"
licenselink = "https://github.com/mirus-ua/hugo-theme-re-terminal/blob/main/LICENSE.md"
description = "A simple, retro theme for Hugo."
homepage = "https://github.com/mirus-ua/hugo-theme-re-terminal/"
tags = [