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

Articles Count #2

Open
akhil-naidu opened this issue May 2, 2020 · 4 comments
Open

Articles Count #2

akhil-naidu opened this issue May 2, 2020 · 4 comments

Comments

@akhil-naidu
Copy link

The number of articles within a category and subcategory is not dynamic. Even though a number of new articles/posts are assigning to the category, the number of articles variable is not updating on the website.

@nickmccullum
Copy link

I encountered the same bug. I think the easiest fix is to simply replace the article count with a static description of that category.

@TomBillingtonUK
Copy link
Contributor

TomBillingtonUK commented Jul 2, 2020

You can set the size manually by adding a size attribute in the category_list.yml file for each category. For example:

#This file defines all the categories you are using
account:
  name: My Account
  description: How to make changes and update your account
  size: 1
payments:
  name: Payments
  description: How to get your payment and more
  size: 17

in index.html I then swapped the category size code to

{% if category[1].size == 1 %}
    <p class="m-0">{{ category[1].size }} article</p>
 {% else %}
    <p class="m-0">{{ category[1].size }} articles</p>
{% endif %}`

@akhil-naidu
Copy link
Author

You can set the size manually by adding a size attribute in the category_list.yml file for each category. For example:

#This file defines all the categories you are using
account:
  name: My Account
  description: How to make changes and update your account
  size: 1
payments:
  name: Payments
  description: How to get your payment and more
  size: 17

in index.html I then swapped the category size code to

{% if category[1].size == 1 %}
    <p class="m-0">{{ category[1].size }} article</p>
 {% else %}
    <p class="m-0">{{ category[1].size }} articles</p>
{% endif %}`

I will let you know if I have any further issues.

@minhtt159
Copy link

You can set the size manually by adding a size attribute in the category_list.yml file for each category. For example:

#This file defines all the categories you are using
account:
  name: My Account
  description: How to make changes and update your account
  size: 1
payments:
  name: Payments
  description: How to get your payment and more
  size: 17

in index.html I then swapped the category size code to

{% if category[1].size == 1 %}
    <p class="m-0">{{ category[1].size }} article</p>
 {% else %}
    <p class="m-0">{{ category[1].size }} articles</p>
{% endif %}`

NO!!!! Don't do that!!!! Let the blog do it automatically.

{% if category[1].size == 1 %}
    <p class="m-0">{{ category[1].size }} article</p>
 {% else %}
    <p class="m-0">{{ category[1].size }} articles</p>
{% endif %}`

Change it to

{% assign post_count = site.categories[category_name].size%}
{% if post_count == nil %}
    <p class="m-0">No article yet</p>
{% elsif post_count == 1 %}
    <p class="m-0">{{ post_count }} article</p>
{% else %}
    <p class="m-0">{{ post_count }} articles</p>
{% endif %}

Please make a pull requests, I'm too tired to make one

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

Successfully merging a pull request may close this issue.

4 participants