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

Subcategories aren't subs! #1135

Closed
Mohamed3nan opened this issue Jul 12, 2023 · 5 comments
Closed

Subcategories aren't subs! #1135

Mohamed3nan opened this issue Jul 12, 2023 · 5 comments

Comments

@Mohamed3nan
Copy link
Contributor

Mohamed3nan commented Jul 12, 2023

NOTE: Before you start, the following should be completed.

  • Read Wiki to understand the usage and the correct effect of functional design.
  • Make sure no similar issue(including closed ones) exists.
  • Make sure the bug is found in the latest code of the master branch.

Describe the bug

Referring to this issue:

Background Note

Post_1

categories: [C_1, S_1]

Post_2

categories: [C_2, S_1]

Expect

  • Post_1 in <url>/categories/C_1/S_1/Post_1
  • Post_2 in <url>/categories/C_2/S_1/Post_2

But,in fact:

  • Post_1 in <url>/categories/S_1/Post_1
  • Post_2 in <url>/categories/S_1/Post_2

Question

  • Is it a bug or by design?
  • if 'by design', how to reach SUB_categories?

thanks a lot.

The current "categories" tab is not working as expected and showing wrong "sub category" because the generated content in _site is all main category and this line in front matter categories: [TOP_CATEGORIE, SUB_CATEGORIE] is also wrong and misleading

image

So in the current situation to remove the confusion and misleading concept "sub category" I suggest removing the subcategory dropdown in the "categories" tab page and make them all main categories (because they are all main in _site) until introducing a real subcategory

Thanks, I hope this makes sense

@Mohamed3nan Mohamed3nan changed the title Sub categories isn't a sub! Sub categories aren't a sub! Jul 12, 2023
@Mohamed3nan Mohamed3nan changed the title Sub categories aren't a sub! Subcategories aren't subs! Jul 12, 2023
@Mohamed3nan
Copy link
Contributor Author

Okay btw I changed the logic for it,
here

---
layout: page
# All the Categories of posts
---

{% include lang.html %}

{% assign HEAD_PREFIX = 'h_' %}
{% assign LIST_PREFIX = 'l_' %}

{% assign group_index = 0 %}

{% assign sort_categories = site.categories | sort %}

{% for category in sort_categories %}
  {% assign category_name = category | first %}
  {% assign posts_of_category = category | last %}

  <div class="card categories">
    <!--category -->
    <div
      id="{{ HEAD_PREFIX }}{{ group_index }}"
      class="card-header d-flex justify-content-between hide-border-bottom"
    >
      <span class="ms-2">
        <i class="far fa-folder{% if posts_of_category.size > 0 %}-open{% endif %}"></i>

        {% capture _category_url %}/categories/{{ category_name | slugify | url_encode }}/{% endcapture %}
        <a href="{{ _category_url | relative_url }}" class="mx-2">{{ category_name }}</a>

        <!-- posts count -->
        {% assign top_posts_size = site.categories[category_name] | size %}
        <span class="text-muted small font-weight-light">      
          {{ top_posts_size }}

          {% if top_posts_size > 1 %}
            {{
              site.data.locales[lang].categories.post_measure.plural
              | default: site.data.locales[lang].categories.post_measure
            }}
          {% else %}
            {{
              site.data.locales[lang].categories.post_measure.singular
              | default: site.data.locales[lang].categories.post_measure
            }}
          {% endif %}
        </span>
      </span>

      <!-- arrow -->
      {% if top_posts_size > 0 %}
        <a
          href="#{{ LIST_PREFIX }}{{ group_index }}"
          data-bs-toggle="collapse"
          aria-expanded="false"
          aria-label="{{ HEAD_PREFIX }}{{ group_index }}-trigger"
          class="category-trigger hide-border-bottom"
        >
          <i class="fa-solid fa-angle-down"></i>
        </a>
      {% else %}
        <span data-bs-toggle="collapse" class="category-trigger hide-border-bottom disabled">
          <i class="fa-solid fa-angle-right"></i>
        </span>
      {% endif %}
    </div>
    <!-- .card-header -->

    <!-- Posts  -->
    <div id="{{ LIST_PREFIX }}{{ group_index }}" class="collapse" aria-expanded="false">
      <ul class="list-group">
        {% for post in posts_of_category %}
          <li class="list-group-item">
            <i class="fa-regular fa-file"></i>
            <a href="{{ post.url | relative_url }}" class="mx-2">{{ post.title }}</a>
            <span class="text-muted small font-weight-light">
              {% include datetime.html date=post.date wrap='span' class='text-muted small' lang=lang %}
            </span>
          </li>
        {% endfor %}
      </ul>
    </div>
  </div>
  <!-- .card -->

    {% assign group_index = group_index | plus: 1 %}
{% endfor %}

Looks good for me!
image

Gonna close this now.

@DylanDijk
Copy link

So this is now just having all categories as main categories?
I also found it misleading that the presentation on the web page made it seem that the subcategories would act as subsets of the categories in the level above.

@NichtsHsu
Copy link
Contributor

Like I said in #893 (comment), this is an issue of jekyll-archives plugin. You can also find a third party solution in that comment.

@DylanDijk
Copy link

@NichtsHsu Ok thank you, does this require all the changes made in this commit?

@NichtsHsu
Copy link
Contributor

This commit only does three things:

  1. Clone jekyll-archives to local .gems/jekyll-archives and add subcategories feature,
  2. Modify Gemfile to point jekyll-archives to the local path,
  3. Update layout files to suit subcategories.

So the answer is yes, all modifications except the README.md are necessary.

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

No branches or pull requests

3 participants