Jamling / hexo-generator-index2

Filtered index generator for Hexo
MIT License
46 stars 8 forks source link

how to only use exclude? #2

Closed yeziahehe closed 6 years ago

yeziahehe commented 7 years ago

I just want to use exclude. But i remove include or include empty, exclude is not work.

Jamling commented 7 years ago

Please see https://github.com/Jamling/hexo-generator-index2#options

v0.1.0 support multi-layout include/exclude

- layout: index
  exclude: 'category'
yeziahehe commented 7 years ago

such as I have three categories : a, b, c. And i only exclude c.

  include:
    - category a
    - category b
  exclude:
    - category c

It is work for me. but if only use

exclude:
    - category c

it does not work.

Jamling commented 7 years ago
  1. if category_map used, please use the value of category_map instead
yeziahehe commented 7 years ago

category_map is not used.

Yalhu commented 6 years ago

On my case: it should uninstall hexo-generator-index and set index2_include_index: false

Jamling commented 6 years ago

@yeziahehe Please try the solution of @Yalhu

The default official hexo-generator-index must uninstalled before using hexo-generator-index2

Yalhu commented 6 years ago

When I open the page: localhost:4000,there is an error: 'cannot get /' while I set index2_include_index:false . Is index2_include_index:true required rather than false? It was ok yesterday.

Jamling commented 6 years ago

@Yalhu https://github.com/Jamling/hexo-generator-index2/blob/master/README_zh.md#%E9%80%89%E9%A1%B9

Yalhu commented 6 years ago

I think it was the code:var include = generator.include || [] indedicating it will include nothing if only using exclude. The include should be all of the categories of level 1 and uncategories what are default if there is no category rather than [] , while there is no include.

But I don't know how to change .

if (generator.include || generator.exclude) {
             //There should include all categories of level 1
             // and uncategories what are default if there is no category
            var include = generator.include || [];
            var exclude = generator.exclude || [];
            if (!util.isArray(include)) {
                include = [include];
            }
            if (!util.isArray(exclude)) {
                exclude = [exclude];
            }

            posts = posts.filter(function (post) {
Jamling commented 6 years ago

I'll check the code tomorrow And run the test of when the include is empty.

Jamling commented 6 years ago

The exclude issue is fix in 0.2.0