1bl4z3r / hermit-V2

Continuing Hermit's legacy to be minimal and fast theme
https://1bl4z3r.github.io/hermit-V2/
MIT License
91 stars 38 forks source link

Request: ability to disable last modified timestamp #30

Closed jamesbraza closed 11 months ago

jamesbraza commented 12 months ago

screenshot of last modified

I see this is part of single.html in v1.0.2, where it has an if .Lastmod conditional.

Any chance we can expose a new config parameter to turn off this behavior? I like the default "creation only" timestamp. Alternately, maybe a post front matter parameter could be useful too

1bl4z3r commented 12 months ago

Hi @jamesbraza,

If you dont supply Lastmod in posts' front matter, it will not show Modified section.

Le me know if you were able to resolve.

jamesbraza commented 12 months ago

For me, my front matter is (it has no Lastmod):

---
title: "Foo"
date: 2023-04-23
draft: false
tags: ["article"]
---

Even explicitly adding Lastmod: false did not turn off the "Modified" text. What am I missing? Any tips?

1bl4z3r commented 12 months ago

Hi again,

It seems to be very strange indeed.

In this post, I have supplied Lastmod as follows.

title: "Typography"
slug : 'typography'
date: 2023-07-22T14:36:33+05:30
draft: false
featuredImg: ""
description : 'Integer lobortis vulputate mauris quis maximus. Vestibulum ac eros porttitor, auctor sem sed, tincidunt nulla. In sit amet tincidunt ex.'
tags: 
  - Demo
  - Typography
Lastmod : 2023-08-15T15:36:33+05:30

I get :

image

Now if I remove:

title: "Typography"
slug : 'typography'
date: 2023-07-22T14:36:33+05:30
draft: false
featuredImg: ""
description : 'Integer lobortis vulputate mauris quis maximus. Vestibulum ac eros porttitor, auctor sem sed, tincidunt nulla. In sit amet tincidunt ex.'
tags: 
  - Demo
  - Typography

I don't get the Lastmod section. image

Please re-check your config if everything is properly formatted and/or do a full recheck on all the files if Lastmod is given somewhere.

jamesbraza commented 12 months ago

Lol I am trying to figure it out, it's got me stumped too

jamesbraza commented 12 months ago

One question, elsewhere I see .Params.tags, but with .Lastmod it's not using Params. Why is it not .Params.Lastmod?

I think .Lastmod is a Hugo-global parameter that is always present

jamesbraza commented 12 months ago

Ahh I see. I have enableGitInfo = true in my config, which seems to globally enable .Lastmod: https://github.com/1bl4z3r/hermit-V2/blob/1ad173d2ab6817d7ca033b28b507df5ba8e08be6/hugo.toml#L32

Any chance you can add in some capability to disable enableGitInfo opting pages into .Lastmod?

1bl4z3r commented 12 months ago

To properly explain your previous query,

There were some changes in Hugo where while defining custom local page variables (i.e. Page Variables whose scope is within the page itself), we can ignore .Params as it is implied that we are trying to fetch local page variables. You can definitely put in .Params.Lastmod and the output would be exactly the same.

It was something to differentiate from inbuilt Page variables and custom Page variables. I am still unsure if we can access custom Page variables from other pages or not.

[EDIT] We can absolutely access custom page variables from outside the page by using .Page.Params.[VARIABLE].

[EDIT 2] StackOverflow guy explains it better than me. https://stackoverflow.com/questions/70808386/using-page-variables-in-hugo

1bl4z3r commented 12 months ago

For enableGitInfo, I am quite unsure how to properly implement this, so that it would not break the core functionality.

If .GitInfo is enabled, we want .Lastmod to be prefilled with the data. It is just extending from core function of .GitInfo. However, if you want to enable .GitInfo and have different date for .Lastmod, there needs to be some value juggling to do.

1bl4z3r commented 12 months ago

Ohkay, here's a big brain moment.

What can be done is in each page a new Page Variable could be setup, whose only job in the world is to enable/disable [Modified:] section. It won't matter if .Lastmod should be shown or not for the post.

If .GitInfo is true and .LastmodEnabler is false, Modified section is not shown If .GitInfo is true and .LastmodEnabler is true, Modified section is shown, Date fetched from git

If .GitInfo is false and .LastmodEnabler is true, Modified section is shown, with each page having a dedicated .Lastmod If .GitInfo is false and .LastmodEnabler is false, Modified section is not shown

Let me know if you want this to be implemented.

jamesbraza commented 12 months ago

I like what you propose! It:

Sounds good to me

1bl4z3r commented 12 months ago

Cool cool cool It shouldn't take me more than 1 business day to implement.

jamesbraza commented 12 months ago

Okay sound good, ahha no need to provide business days here, it's FOSS babyyyy

1bl4z3r commented 11 months ago

Implemented. Same is updated on #last-modified-date

If IgnoreLastmod is not provided or IgnoreLastmod=false, then:

Closing this issue. Re-open if required.

1bl4z3r commented 11 months ago

Not Fixed yet

1bl4z3r commented 11 months ago

This is finalfinalfinal. As usual, details updated in #last-modified-date

If ShowLastmod:true :

If ShowLastmod is not provided. User response defaults to false. It is equivalent to providing ShowLastmod:false.

1bl4z3r commented 11 months ago

And I was wrong. Any Page Variable should be called via .Page.Params. if you ignore .Page or .Site, . by default has Global scope. .Lastmod is inbuilt Hugo Variable attached with GitInfo, hence it has global scope.