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

Only one class is allowed on `list_tags` helper #3226

Open
Xaviju opened this Issue Aug 1, 2018 · 6 comments

Comments

2 participants
@Xaviju

Xaviju commented Aug 1, 2018

Feature request

Allow multiple classes on list_tags helper

Currently only one class is allowed on thelist_tags helper because it transforms the class and applies classes to this element and its children.

Would be quite easy and useful to allow multiple classes in an array and apply all transformations in the HTML generation, but would like to listen to your opinion before digging into code.

@tcrowe

This comment has been minimized.

Show comment
Hide comment
@tcrowe

tcrowe Aug 20, 2018

Contributor

Hey @Xaviju 👋

What happens if you used class1 class2 class3 on the list_tags class option?

Contributor

tcrowe commented Aug 20, 2018

Hey @Xaviju 👋

What happens if you used class1 class2 class3 on the list_tags class option?

@Xaviju

This comment has been minimized.

Show comment
Hide comment
@Xaviju

Xaviju Aug 21, 2018

Hi @tcrowe

🤔 It currently works, but not as expected. Let me explain:

According to this code it will get the string on the list_tags class option and applies a string to it.

Example

If I add multiple classes like this:

<%- list_tags({
    class: "main-tag secondary-tag"
}) %>

Current generated code

<ul class="main-tag secondary-tag-list">
    <li class="main-tag secondary-tag-list-item">
        <a class="main-tag secondary-tag-list-link" href="#">Something</a>
    </li>
</ul>

Expected

<ul class="main-tag secondary-tag tag-list">
    <li class="main-tag secondary-tag tag-list-item">
        <a class="main-tag secondary-tag tag-list-link" href="#">Something</a>
    </li>
</ul>

Sorry if the issue is not well explained, please feel free to edit it

Xaviju commented Aug 21, 2018

Hi @tcrowe

🤔 It currently works, but not as expected. Let me explain:

According to this code it will get the string on the list_tags class option and applies a string to it.

Example

If I add multiple classes like this:

<%- list_tags({
    class: "main-tag secondary-tag"
}) %>

Current generated code

<ul class="main-tag secondary-tag-list">
    <li class="main-tag secondary-tag-list-item">
        <a class="main-tag secondary-tag-list-link" href="#">Something</a>
    </li>
</ul>

Expected

<ul class="main-tag secondary-tag tag-list">
    <li class="main-tag secondary-tag tag-list-item">
        <a class="main-tag secondary-tag tag-list-link" href="#">Something</a>
    </li>
</ul>

Sorry if the issue is not well explained, please feel free to edit it

@tcrowe

This comment has been minimized.

Show comment
Hide comment
@tcrowe

tcrowe Aug 23, 2018

Contributor

I tested it and I see that it always appends -list to the class.

result += '<ul class="' + className + '-list">';

For now want to try an alternative?

./source/_posts/hello-world.md

---
title: Hello World
categories:
- catone
- cattwo
- catthree
tags:
- tagone
- tagtwo
- tagthree
---
Welcome to [Hexo](https://hexo.io/)!

./themes/your-theme/layout/_partial/post-tag-list.ejs

<!--

for post tags only. page tags are different

-->

<div class="<%=containerClass || 'post-tag-list'%>">
  <% page.tags.each(tag => { %>
    <div class="<%=itemClass || 'post-tag-item'%>">
      <a class="<%=linkClass || 'post-tag-link'%>" href="<%=url_for(tag.path)%>">
        <%=tag.name%>
        <span class="<%=countClass || 'post-tag-count'%>"><%=tag.length%></span>
      </a>
    </div>
  <% }) %>
</div>

./themes/your-theme/layout/post.ejs

<%- partial('_partial/article', {post: page, index: false}) %>

<%-partial('_partial/post-tag-list', {
  containerClass: 'custom-tag-list',
  itemClass: 'custom-tag-item',
  linkClass: 'custom-tag-link',
  countClass: 'custom-tag-count'
})%>
Contributor

tcrowe commented Aug 23, 2018

I tested it and I see that it always appends -list to the class.

result += '<ul class="' + className + '-list">';

For now want to try an alternative?

./source/_posts/hello-world.md

---
title: Hello World
categories:
- catone
- cattwo
- catthree
tags:
- tagone
- tagtwo
- tagthree
---
Welcome to [Hexo](https://hexo.io/)!

./themes/your-theme/layout/_partial/post-tag-list.ejs

<!--

for post tags only. page tags are different

-->

<div class="<%=containerClass || 'post-tag-list'%>">
  <% page.tags.each(tag => { %>
    <div class="<%=itemClass || 'post-tag-item'%>">
      <a class="<%=linkClass || 'post-tag-link'%>" href="<%=url_for(tag.path)%>">
        <%=tag.name%>
        <span class="<%=countClass || 'post-tag-count'%>"><%=tag.length%></span>
      </a>
    </div>
  <% }) %>
</div>

./themes/your-theme/layout/post.ejs

<%- partial('_partial/article', {post: page, index: false}) %>

<%-partial('_partial/post-tag-list', {
  containerClass: 'custom-tag-list',
  itemClass: 'custom-tag-item',
  linkClass: 'custom-tag-link',
  countClass: 'custom-tag-count'
})%>
@Xaviju

This comment has been minimized.

Show comment
Hide comment
@Xaviju

Xaviju Aug 28, 2018

@tcrowe thanks for the alternative method.

I tested it and I see that it always appends -list to the class.
Not only to the parent element, also to the child elements in the list tree.

Should the helper be fixed? I can try to do it :)

Xaviju commented Aug 28, 2018

@tcrowe thanks for the alternative method.

I tested it and I see that it always appends -list to the class.
Not only to the parent element, also to the child elements in the list tree.

Should the helper be fixed? I can try to do it :)

@tcrowe

This comment has been minimized.

Show comment
Hide comment
@tcrowe

tcrowe Aug 28, 2018

Contributor

I guess I'm not sure what the original intent was behind that helper class option. 😬

Maybe someone who knows can tell us. git blame ... might help us find who to ask.

Contributor

tcrowe commented Aug 28, 2018

I guess I'm not sure what the original intent was behind that helper class option. 😬

Maybe someone who knows can tell us. git blame ... might help us find who to ask.

@Xaviju

This comment has been minimized.

Show comment
Hide comment
@Xaviju

Xaviju Aug 30, 2018

According to the file history, the list_tags helper class list was created on this commit and has never been modified since then (bcdfb29#diff-8261f6bff72a6e1eb8a1c5307939a28d) by @tommy351 maybe he might help us.

Xaviju commented Aug 30, 2018

According to the file history, the list_tags helper class list was created on this commit and has never been modified since then (bcdfb29#diff-8261f6bff72a6e1eb8a1c5307939a28d) by @tommy351 maybe he might help us.

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