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

Add Tag index page #2

Merged
merged 2 commits into from
Jul 20, 2015
Merged

Add Tag index page #2

merged 2 commits into from
Jul 20, 2015

Conversation

creeperyang
Copy link
Contributor

Add tag index page generation for hexo-generator-tag.

After generation, it would be like:

public--
       |--tags--
                |----index.html (added)
                |----xxx

So like /tag menu will be supported.

@Xuanwo
Copy link

Xuanwo commented Jul 15, 2015

will it override my tags new?

@creeperyang
Copy link
Contributor Author

No, just append to your generated pages or do nothing, controlled via tag_generator option:

tag_generator:
  per_page: 10
  # append index page or do nothing
  enable_index_page: true/false
  # if enable_index_page: true, config template to use. ['tagIndex', 'tag', 'archive', 'index']
  template: 'tagIndex' 

@tommy351
Copy link
Member

LGTM 👍

pages.push({
path: tagDir,
layout: [tagConfig.template ? tagConfig.template :
'tagIndex', 'tag', 'archive', 'index'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use:

[].concat(tagConfig.template, ['tagIndex', 'tag', 'archive', 'index']);

In this way, users will still have the template fallback when the template does not exist. Also I think tag-index would be better than tagIndex.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your suggestion seems to be better. :)

@creeperyang
Copy link
Contributor Author

@tommy351 I make a change after look through the source code of archive and category generator. And now, there is only one config option enable_index_page: true/false.

For template, it's of a particular sequence ['tag-index', 'tag', 'archive', 'index'].

@borisschapira
Copy link
Contributor

+1

tommy351 added a commit that referenced this pull request Jul 20, 2015
@tommy351 tommy351 merged commit dfa2bf8 into hexojs:master Jul 20, 2015
@borisschapira
Copy link
Contributor

@creeperyang I would like to use it but I can't manage to understand how to do it. Could you please explain ?

I've set this in configuration :

tag_generator:
  enable_index_page: true
  # if enable_index_page: true, config template to use. ['tagIndex', 'tag', 'archive', 'index']
  template: 'tagIndex' 

And added a tagIndex.ejs to my theme's supported layout. Anything else ?

@creeperyang
Copy link
Contributor Author

@borisschapira A little change done and now it's stable(merged). So currently the config is like:

tag_generator:
  per_page: 10
  # append index page or do nothing ------ the only config option
  enable_index_page: true/false
  # template: 'tagIndex' ------ removed, default to 'tag-index', so use 'tag-index.ejs' instead.

And the variables inserted into the template(tag-index) are like:

{
        base: tagDir,
        total: 1,
        current: 1,
        current_url: tagDir,
        posts: locals.posts, // all posts
        prev: 0,
        prev_link: '',
        next: 0,
        next_link: '',
        tags: tags // all tags
 }

Last, I check via npm info hexo-generator-tag and @tommy351 hasn't made a new release. So you have to clone the repo if you want to use now.

@borisschapira
Copy link
Contributor

Thanks for the answer, it works.

Maybe you should Pull-Request some evolution to the documentation with all of that info.

Last, I check via npm info hexo-generator-tag and @tommy351 hasn't made a new release. So you have to clone the repo if you want to use now.

✋ You can reference the repo like that to get last commit on master 😄

  "dependencies": {
    ...
    "hexo-generator-tag": "hexojs/hexo-generator-tag",
    ...
}

@borisschapira
Copy link
Contributor

@creeperyang Do you plan to do the same with hexojs/hexo-generator-category ? If yes, maybe you should harmonize the structure of data passed to tag-index to allow the use of a master template (taxonomy-index ?) allowing the listing of tags or categories, regarding the route.

@borisschapira
Copy link
Contributor

@creeperyang : another note : you list all the tags, including the tags of non-published drafts (therefor, the tag page does not necessarily exists). I suggest you filter on tag.length.

@borisschapira
Copy link
Contributor

@creeperyang : and maybe also add a configuration for desired order (alpha, length, reverse...).

@creeperyang
Copy link
Contributor Author

@borisschapira Good suggestions. But currentlly I have no time to do it. And I use issues to write blog now. Maybe it's a common demand to generate index page for tag and category, I'll fulfill it if the maintainers wont do it.

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 this pull request may close these issues.

4 participants