Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip menu entry if no title #88

Open
mcnesium opened this issue Nov 4, 2020 · 2 comments
Open

Skip menu entry if no title #88

mcnesium opened this issue Nov 4, 2020 · 2 comments
Labels
feedback waiting for feedback on the issue fixed? Issue fixed, waiting for confirmation

Comments

@mcnesium
Copy link

mcnesium commented Nov 4, 2020

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
Copy link
Owner

avillafiorita commented Nov 7, 2020

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

@avillafiorita avillafiorita added feedback waiting for feedback on the issue fixed? Issue fixed, waiting for confirmation labels Nov 7, 2020
@mcnesium
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback waiting for feedback on the issue fixed? Issue fixed, waiting for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants