monkeyWzr / hugo-theme-cactus

Cactus theme for hugo
MIT License
537 stars 338 forks source link

Projects list params badly taken into account #20

Closed ronangaillard closed 3 years ago

ronangaillard commented 3 years ago

If you have

[params]
  showProjectsList = false

in your config file, but you also have a data/projects.json in your project, the main page will display the projects anyway.

I wanted to fix it by changing the index.html template with

{{ $showProjectsList := false }}
  {{ if (isset .Site.Params "showProjectsList") }}
    {{ $showProjectsList = .Site.Params.showProjectsList }}
  {{ else if .Site.Data.projects }}
    {{ $showProjectsList = true }}
  {{ end }}

but it still does not work (projects are still shown), I'm not a go template expert though

monkeyWzr commented 3 years ago

@ronangaillard hey there, so sorry for the delay and really appreciate your help!

We should use lower case when checking the key by isset. Hugo stores all site-level configuration keys as lower case. https://gohugo.io/functions/isset/

isset .Site.Params "showprojectslist" will work.

Would you like to make a pr on that? (the logic I wrote was totally a mess. Thanks again!)

ronangaillard commented 3 years ago

I'll try to make a PR soon yes :)

monkeyWzr commented 3 years ago

@ronangaillard Hi there! This has been fixed in #77.

Best regards!