npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hexo-generator-anything

v1.0.12

Published

Hexo plugin to generate index pages from custom front matter variables

Downloads

9

Readme

GitHub package.json version issues npm

hexo-generator-anything

Hexo plugin to generate index pages from custom front matter variables.

:information_source: This project is a fork from hexo-index-anything by Levi Wheatcroft, who is no longer maintaining the project. I have refactored the code and introduced some new features ... see below.

Introduction

Suppose you have an author variable in your front matter, this plugin will generate an overview page of all authors (called INDEX) and for each author, a listing page with all posts by that author (POSTS).

You can define multiple indexes to be created, by configuring several index-mappings out of your Frontmatter variables (see Configuration).

Example

The Frontmatter data of the following two posts...

../source/_posts/post-1.md

---
title: First Post
author: Maria
---

../source/_posts/post-2.md

---
title: Second Post
author: Jonas
---

../source/_posts/post-3.md

---
title: Third Post
author: Jonas
---

... will lead to:

  • ../output/author/index.html
    INDEX file with a link list of all authors

  • ../output/author/maria.html
    POSTS file with list of all posts from Maria, here 'First Post' only

  • ../output/author/jonas.html
    POSTS file with list of all posts from Jonas, here 'Second Post' and 'Third Post'

If you have activated the Hexo configuration attribute post_asset_folder, then the output will be:

  • ../output/author/index.html
  • ../output/author/maria/index.html
  • ../output/author/jonas/index.html

Installation

npm install hexo-generator-anything --save

Configuration

_config.yml

To configure the plugin, add following section to your Hexo's root _config.yml:

anything:
  layout_index: anything-index
  layout_posts: anything-posts
  index_mappings:
    - variable: author
      path: author
    - variable: my-other-variable
      path: others

The settings in depth:

| Settings | Description | |---------|------------| | layout_index | EJS template for processing INDEX file(if not set, Hexo's default index.ejs will be used) | | layout_posts | EJS template for processing POSTS file(if not set, Hexo's default index.ejs will be used) | | index_mappings | List of Anything mappings | | ... variable | Frontmatter variable in your posts to generate an index of | | ... path | Part of the path of the output files, which represents the index |

You can find examples for layout_index.ejs and layout_posts.ejs in the package samples folder under /node_modules/hexo-generator-anything/ after installation. Place the files in your Hexo's layout folder.

Additional Markdown Files

For generating the INDEX page, you can enrich the information about each author (variable value = key), by providing a Markdown file in in your sources folder: ../source/anything/{index}/{key}.

To stay with the example above, we have in index called authors and two keys: maria and jonas:

|- source
|  |- _anything
|  |  |- authors
|  |  |  |-> maria.md
|  |  |  |-> jonas.md 

Each of these files has to have at least one Frontmatter variable called title, where you can overwrite the default key string (value of the index variable in the posts). You can extend the Frontmatter with as many variables as you want and use it in your INDEX EJS template.

The content of the MD file will also be available in the data for generating the INDEX page.

Example:

---
title: Marias Posts
avatar: ./photos/maria.jpg
email: [email protected]
---

Maria is writer of the month. Don't miss her tweets on [https://twitter.com/maria](https://twitter.com/maria)

The INDEX page itself, may have a linked Markdown file too, to provide content or additional data:

|- source
|  |- _anything
|  |  |- authors
|  |  |  |-> index.md
|  |  |  |-> ...

Usage

Install, configure, then run hexo generate as usual.

Contributing

Yes, please ... fork the project, make your changes and submit pull requests against the main branch.

Demo

I have created this project for my blog and I use it to group some posts into series. You can see the result at: https://kiko.io/series

More Information

I have a section for this project on my blog with posts regarding this project (automatically generated by this plugin ;) at http://kiko.io/projects/hexo-generator-anything

History

1.0.5

  • Path fix (Lowercase)

1.0.4

  • Replaced vulnerable string.js library

1.0.3

  • Refactorings
  • Introducing Markdown file for INDEX page
  • titleSeparator setting removed
  • Updated samples

1.0.1/2

  • Markdown data fix

1.0.0

  • Initial version

License

MIT : http://opensource.org/licenses/MIT

Codebase Vizualization

For an inactive diagram, please visit Repo Visualization App... Visualization of the codebase