Skip to content

Commit

Permalink
fixed getting post editng date from git
Browse files Browse the repository at this point in the history
  • Loading branch information
danieltomasz committed Aug 5, 2023
1 parent 3ab50a1 commit 416ad50
Show file tree
Hide file tree
Showing 33 changed files with 31 additions and 141 deletions.
1 change: 1 addition & 0 deletions .github/workflows/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
hugo \
--gc \
--minify \
--enableGitInfo \
--baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ Currently, I am based in Brussels, Belgium.

You can find me on [Twitter](https://twitter.com/danielborek), [GitHub](https://github.com/danieltomasz), and [Mastodon](https://scholar.social/@dborek)

## TODO

- Fix favicons
- Fix rendering time of editing from github
11 changes: 7 additions & 4 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,26 @@ theme = 'lines'
reactionsEnabled = "1"

[params.assets]
favicon = "https://danielborek.me/assets/favicon.ico"
favicon = "img/favicon.ico"

enableGitInfo = true
enableEmoji = true

[frontmatter]
date = [":filename", ":default", "lastmod"]
# date = [":filename", ":default", "lastmod"]
author = "Daniel Borek"
github = "danieltomasz"
facebook = ""
og_image = ""
sitename = ""
twitter = "danieltomasz"
lastmod = ["lastmod", ":git", "date", "publishDate"]
date = ["date", "publishDate", "lastmod"]
lastmod = [ "lastmod", ":git", "date", ]
publishDate = ["publishDate", "date"]
expiryDate = ["expiryDate"]
#disableKinds = ["section", "categories"]


#disableKinds = ["section", "categories"]
disqusShortname = ""
pygmentsStyle = "pygments"
pygmentsCodefences = true
Expand Down
14 changes: 10 additions & 4 deletions content/posts/back to hugo.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ I try this setting within the markup section,

### Rendering mermaid diagrams

Paul Johnson describe his setup in [ this blogpost](https://www.paulrjohnson.net/2022/09/rendering-mermaid-diagrams-on-a-hugo-website-using-quarto/).
Paul Johnson describe his setup in [this blogpost](https://www.paulrjohnson.net/2022/09/rendering-mermaid-diagrams-on-a-hugo-website-using-quarto/).


### Adding comments with `giscus`

I followed various blogpost with the configuration advices.
By default, `giscus` is adding comments to every page, but I wanted to have comments only on my posts.
I followed advice[^1] and I wrapped my addition of `giscus` partial into `footer.html` with `if` statement:
I followed advice[^2] and I wrapped my addition of `giscus` partial into `footer.html` with `if` statement:

```hugo
{{ if not .Params.noComment }}
Expand All @@ -137,12 +137,18 @@ When I don't want to include a comments block, I am adding this in the frontmatt
noComment: true
```
[^1]: [How to disable comments in specific pages? - support - HUGO](https://discourse.gohugo.io/t/how-to-disable-comments-in-specific-pages/22177/2)
[^2]: [How to disable comments in specific pages? - support - HUGO](https://discourse.gohugo.io/t/how-to-disable-comments-in-specific-pages/22177/2)
Some other useful links: https://www.brycewray.com/posts/2022/05/tips-using-giscus/
### Date of last edit directly from github
Some advice how to set up it: [Add a Last Edited Date to Posts · Make with Hugo](https://makewithhugo.com/add-a-last-edited-date/).
Frankly, I wasn't able to get it fully working yet.
One caveat: setting `enableGitInfo` to `true` in your site’s configuration file is not enough[^3]. You have to add `--enableGitInfo` to get `.GitInfo`:

```bash
hugo serve --enableGitInfo
```

[^3]: [Add git commit date as last update date in hugo page](https://djangocas.dev/blog/add-git-commit-date-as-last-update-date-in-hugo-page/)
5 changes: 4 additions & 1 deletion layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@

{{ if eq .Type "posts" }}
<h2 itemprop="name headline">{{ .Title }}</h2>
{{ $date := .Date.Format "02.01.2006" }}
{{ $lastmod := .Lastmod.Format "02.01.2006" }}

<p class="meta">

<time itemprop="datePublished" datetime="{{ dateFormat "2006-01-02" .Date }}">{{ dateFormat " January 02, 2006" .Date }}</time> &bull;
{{ partial "tags.html" .}}
<br> Edited on: <time datetime="{{ .Lastmod }}" title="{{ .Lastmod }}">{{ $lastmod }}</time>
{{/* %{{ if ne $lastmod $date }} */}}
<span class="date-info italic"> <br> Edited on {{ .Lastmod.Format "02.01.2006" }}</span>
{{/* {{ end }} */}}
</p>


Expand Down
3 changes: 1 addition & 2 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Daniel Borek - {{ .Site.BaseURL }}">
<meta name="author" content=" {{ .Site.Author }} - {{ .Site.BaseURL }}">
<title>{{ if eq .IsHome true }}{{ .Site.Title }}{{ else }}{{ .Title }} | {{ .Site.Title }}{{ end }}</title>
<meta name="description" content="{{ if ne .Description "" }}{{ .Description }}{{ else }}{{ .Site.Params.description }}{{ end }}">
{{ template "_internal/twitter_cards.html" . }}
Expand All @@ -13,7 +13,6 @@
<link href="https://www.google-analytics.com" rel="preconnect" crossorigin>
<link rel="alternate" type="application/atom+xml" title="{{ .Site.Title }}" href="{{ .Site.BaseURL }}atom.xml" />
<link rel="alternate" type="application/json" title="{{ .Site.Title }}" href="{{ .Site.BaseURL }}feed.json" />
<link rel="shortcut icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=">
{{ $styles := resources.Get "scss/styles.scss" | toCSS (dict "outputStyle" "compressed") | minify }}
<style>{{ $styles.Content | safeCSS }}</style>

Expand Down
25 changes: 0 additions & 25 deletions public/2023/08/03/back-to-hugo/index.html

This file was deleted.

Loading

0 comments on commit 416ad50

Please sign in to comment.