Code Monkey home page Code Monkey logo

hexo-generator-index's People

Contributors

curbengh avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar iissnan avatar jimniels avatar leesei avatar miballe avatar noahdragon avatar rgfindl avatar segayuu avatar stevenjoezhang avatar sukkaw avatar tomap avatar tommy351 avatar yoshinorin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hexo-generator-index's Issues

`index_generator.pagination_dir` doesn't take effect

Check List

  • I have already read README.
  • I have already searched existing issues and they are not help to me.
  • I examined error or warning messages and it's difficult to solve.
  • I am using the latest version of this repository.
  • I am using the latest version of Hexo.
  • My Node.js is matched the required version.

Describe the bug

``` yaml
index_generator:
path: ''
per_page: 10
order_by: -date
pagination_dir: page
```

according to README, pagination_dir can be set by index_generator.pagination_dir.
But from the code, index_generator.pagination_dir is invalid.

const paginationDir = config.pagination_dir || 'page';

Expected behavior

Code and documentation should match, avoid misleading users.

How to reproduce

Screenshots

No response

Environment information

No response

Additional context

No response

some posts don't show on the home page

for some reasons ,I need to hide some post,I do the procedure as follow:

  1. change he them/next/laytout/index.swig to like this:
    `

    {% for post in page.posts %}
    {% if post.visible !== 'hide'%}
    {{ post_template.render(post, true) }}
    {% endif %}
    {% endfor %}
` as it shows , I add a judgement to make it don't render the post when I set the post's attribute visible to hide.

then it show error!

it divide posts before redering which make the number of post in some page fewer than other pages.

you can visite my blog http://chenfengkg.cn.

my slution is to make redering post be first ,then divide page.so this can slove this problem.but I don't know how to change your code ,can you help me .or do you have any other solution? Thanks in advance.

How to add custom things into index?

I want to add some words or HTML tags or markdowns into index, and keep the generated index rendered to, all solution I find can only create a custom index and remove this plugin, but I don't want to remove this plugin's index.

Is there anyway to keep both of those?

Make layout configurable

As the 'index' layout is used not only for index generation but also as fallback layout, it would be nice to be able to specify a different layout for the blog.

My use case is that I have a site that has a static page as index /and many other static pages...) and a blog in a subfolder. This basically works, but i loose the layout fallback the way it is right now.

TypeError: Cannot read property 'call' of undefined

When I run npm run test-cov, then I get some errors

[zjf@aliyun hexo-generator-index]$ npm run test-cov

> [email protected] test-cov /home/zjf/git/hexo-generator-index
> istanbul cover --print both _mocha -- test/index.js



(node:3175) [DEP0061] DeprecationWarning: fs.SyncWriteStream is deprecated.
  Index generator
    1) "before all" hook


  0 passing (26ms)
  1 failing

  1) Index generator "before all" hook:
     TypeError: Cannot read property 'call' of undefined
      at Model._Document.Document.<anonymous> (node_modules/[email protected]@hexo/lib/models/post.js:60:30)
      at Model._Document.Document.permalink (node_modules/[email protected]@warehouse/lib/types/virtual.js:70:22)
      at Model._Document.Document.Document.toObject (node_modules/[email protected]@warehouse/lib/document.js:79:42)
      at Database._Model.Model.Model._insertOne (node_modules/[email protected]@warehouse/lib/model.js:189:21)
      at node_modules/[email protected]@warehouse/lib/model.js:214:17
      at tryCatcher (node_modules/[email protected]@bluebird/js/release/util.js:16:23)
      at node_modules/[email protected]@bluebird/js/release/using.js:185:26
      at tryCatcher (node_modules/[email protected]@bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (node_modules/[email protected]@bluebird/js/release/promise.js:512:31)
      at Promise._settlePromise (node_modules/[email protected]@bluebird/js/release/promise.js:569:18)
      at Promise._settlePromise0 (node_modules/[email protected]@bluebird/js/release/promise.js:614:10)
      at Promise._settlePromises (node_modules/[email protected]@bluebird/js/release/promise.js:693:18)
      at Promise._fulfill (node_modules/[email protected]@bluebird/js/release/promise.js:638:18)
      at PromiseArray._resolve (node_modules/[email protected]@bluebird/js/release/promise_array.js:126:19)
      at PromiseArray._promiseFulfilled (node_modules/[email protected]@bluebird/js/release/promise_array.js:144:14)
      at Promise._settlePromise (node_modules/[email protected]@bluebird/js/release/promise.js:574:26)
      at Promise._settlePromise0 (node_modules/[email protected]@bluebird/js/release/promise.js:614:10)
      at Promise._settlePromises (node_modules/[email protected]@bluebird/js/release/promise.js:693:18)
      at Async._drainQueue (node_modules/[email protected]@bluebird/js/release/async.js:133:16)
      at Async._drainQueues (node_modules/[email protected]@bluebird/js/release/async.js:143:10)
      at Immediate.Async.drainQueues (node_modules/[email protected]@bluebird/js/release/async.js:17:14)



=============================================================================
Writing coverage object [/home/zjf/git/hexo-generator-index/coverage/coverage.json]
Writing coverage reports at [/home/zjf/git/hexo-generator-index/coverage]
=============================================================================
---------------|----------|----------|----------|----------|----------------|
File           |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
---------------|----------|----------|----------|----------|----------------|
 lib/          |    28.57 |        0 |        0 |    28.57 |                |
  generator.js |    28.57 |        0 |        0 |    28.57 |     6,7,8,9,11 |
---------------|----------|----------|----------|----------|----------------|
All files      |    28.57 |        0 |        0 |    28.57 |                |
---------------|----------|----------|----------|----------|----------------|


=============================== Coverage summary ===============================
Statements   : 28.57% ( 2/7 )
Branches     : 0% ( 0/4 )
Functions    : 0% ( 0/1 )
Lines        : 28.57% ( 2/7 )
================================================================================
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test-cov: `istanbul cover --print both _mocha -- test/index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] test-cov script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/zjf/.npm/_logs/2017-06-25T17_02_28_120Z-debug.log

I don't know how to solve it, can anyone help me?

Add sorting option

The sorting is hardcoded as

var posts = locals.posts.sort('-date');

Can it be made into hexo.config?

Add a feature to exclude articles based on categories in paging

_config.yml

index_generator:
  path: ''
  per_page: 10
  order_by: -date
  exclude: true  //set true if you wanna exclude
  exclude_list:
    - novel   //set categories name you wanna exclude
    - gossip    //set categories name you wanna exclude

generator.js

'use strict';

const pagination = require('hexo-pagination');
const { sort } = require('timsort');

module.exports = function(locals) {
  const config = this.config;
  const posts = locals.posts.sort(config.index_generator.order_by);
  const temp_posts = [];

  sort(posts.data, (a, b) => (b.sticky || 0) - (a.sticky || 0));

  const paginationDir = config.pagination_dir || 'page';
  const path = config.index_generator.path || '';

  if(config.index_generator.exclude){
    
    posts.forEach(element => {
      var mark=true; 
      element.categories.forEach(function(categories){ 
        config.index_generator.exclude_list.forEach(function(category){
          if(categories.name == category){
            mark=false; 
          }
        });
      }); 
      if(mark){
        temp_posts.push(element);
      }    
    });
  }

  return pagination(path, config.index_generator.exclude ? temp_posts : posts, {
    perPage: config.index_generator.per_page,
    layout: ['index', 'archive'],
    format: paginationDir + '/%d/',
    data: {
      __index: true
    }
  });
};

First page url incorrect

I've got following configuration in my _config.yml

url: http://website.com/child
root: /child/

index_generator:
per_page: 10

And the link to first page will always take me to http://website.com , instead of https://website.com/child

This problem cannot be reproduced on Hexo server, because it always redirect http://localhost:4000/ to http://localhost:4000/child

it seemed in:

hexo-pagination/lib/pagination.js

Some special handling is needed for the first page. But I cannot find where since I'm not familiar with Hexo.

Are there more order options?

I noticed that the order option has been made into _config.yml, but I can't find more order options from hexo's official document.

# order_by: Posts order. (Order by date descending by default)
  order_by: -date

Does it seem to be less humanity for only ordering by created date?

Due to my poor JS knowledge, if I miss more order options, can u update the hexo doc plz?

Add info about the index_generator to the official documentation

I spent so many hours trying to find out how to have a blog section (instead of using index as the blog page) together with a regular static index page in my hexo generated website.

I then found out through github issues that I could add a:

index_generator:
  path: '/blog'

section to my config file to make it work (which it did!). However this should really be in the documentation or even the default _config.yml since it must be a pretty normal use case? Can we add it? Thank you for a great product!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.