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

Bug: user-centered design tag index not showing all posts #1947

Closed
awfrancisco opened this issue Oct 17, 2016 · 4 comments
Closed

Bug: user-centered design tag index not showing all posts #1947

awfrancisco opened this issue Oct 17, 2016 · 4 comments

Comments

@awfrancisco
Copy link

awfrancisco commented Oct 17, 2016

The tag list shows 27 posts with the tag user-centered design user-centered-design

But the page only shows 1 post.

@awfrancisco
Copy link
Author

I believe this could be fixed by adding a hyphen to the one post that is tagged user centered design but I'll wait to do that in case anyone wants to diagnose the deeper problem.

@coreycaitlin
Copy link

One concern is whether "fixing" this for our purposes, then contributing that back to the plugin project, would impose our style choices on other users, which might not be totally appropriate.

Next steps:

@gboone
Copy link
Contributor

gboone commented Oct 18, 2016

Here is the related issue I opened with the Jekyl Archives project back in the day jekyll/jekyll-archives#43

@gemfarmer
Copy link
Contributor

gemfarmer commented Nov 5, 2016

Ok, so I did a bit more research on this today.

Assuming that we want to monkey patch this instead of messing with Jekyll Archives itself (probably less likely to spawn new bugs), there are two major things we need to do.

  1. Update the tags on each once Jekyll and the Jekyll::Archives modules have been initialized. Because the tags index page looks for tags in each post, this effectively consolidates tags like user-centered design and user centered design. I got this to work with the following code:
def clean_tags(tags)
  cleaned_tags = []
  tags.each do |tag|
    cleaned_tags << tag.gsub(/[^0-9A-Za-z]/, ' ').squeeze
  end
  cleaned_tags
end

Jekyll::Hooks.register :posts, :pre_render do |post|
  tags = post.data['tags'] || []
  if tags.any?
    post.data['tags'] = clean_tags(post.data['tags'])
  end
end
  1. Update the Jekyll:Archives module itself before it initializes. When Jekyll archives instantiates each archive it relates a given archive page (tag page) with the posts that share its tag. We somehow need to either
    • update each post page to have proper tag names OR
    • cull the archive relations that have improper tag names and supplant its related posts into the array of posts that belong to the proper version of that tag name

There doesn't seem to be much documentation on this on stackoverflow, github, or blogs (people don't mess around with Jekyll core monkey patching I guess), so the most useful documentation has been the Jekyll Archives rubydocs API and the Jekyll Hooks docs

This might feel like overkill for a small bit of tag consolidation, but it has been really helpful to understand how Jekyll hooks works and how the Jekyll Archives core operates.

@mugizico @monfresh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants