avillafiorita / jekyll-datapage_gen

Generate one page per yaml record in Jekyll sites.
367 stars 79 forks source link

Skip menu entry if no title #88

Open mcnesium opened 3 years ago

mcnesium commented 3 years ago

Hi, thank you for sharing this great plugin.

Sorry if I overlooked it, but is it possible to not have links to the pages in the page menu? I have too many data items :)

On regular pages, if no title: key is in the frontmatter, no menu entry will be created. This plugin in that case uses name: from _config.yml instead. It looks like this:

page_gen:
  - data: projects
    template: project
    name: slug

How can I remove the titles from the menu? By now I can only make them display: none with some CSS.

avillafiorita commented 3 years ago

Hi, thanks for the request. It seems like there is a quick fix for this.

  1. comment line 79 of lib/jekyll-datapage-generator.rb (the return statement in):
        if raw_title == nil
          puts "error (datapage-gen). title_expr '#{title_expr}' generated an empty value in record #{data}"
          # return
        end
  1. Add a title_expr to your dataset which returns nil:
   title_expr: nil

Let me know if it works. I will fix the code in the next release.

Note that to make the change, you can either patch the gem or, better, install the source code of the plugin in the _plugins directory of your website.

As a afterthought: this adds an empty title field in the page. If you need to remove the key altogether, you also need to change line 109, adding the if raw_title condition:

  self.data['title'] = raw_title if raw_title
mcnesium commented 2 years ago

Almost one year later I am hitting this issue again. Please excuse me for not getting back to your reply.

As in my current (and probably future) setting, I can only include this plugin as a gem and thus I am unable to fiddle in the plugin code, so I need to use CSS to hide the menu items.

Leaving my personal issue aside, I really think it makes sense to have the page generation of this plugin behave just like the regular page generation. That is, if no title: key is in the frontmatter, no menu entry will be created, as I already stated above.