Last active
May 24, 2020 17:04
-
-
Save mh61503891/544d3c1eefd00b1012463b860222d34f to your computer and use it in GitHub Desktop.
List all tags, categories, and posts in Hexo for Front-Matters of Markdown Writer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See: https://github.com/zhuochun/md-writer/wiki/Settings-for-Front-Matters | |
// Path: scripts/meta.js | |
// Author: Masayuki Higashino | |
// License: MIT | |
hexo.extend.generator.register('meta', function(locals) { | |
var meta = { | |
tags: [], | |
posts: [], | |
categories: [] | |
} | |
locals.tags.sort('name').each(function(tag) { | |
meta.tags.push(tag.name) | |
}) | |
locals.categories.sort('name').each(function(category) { | |
meta.categories.push(category.name) | |
}) | |
locals.posts.sort('name').each(function(post) { | |
meta.posts.push({ | |
title: post.title, | |
url: encodeURI(post.permalink), | |
date: post.updated.toDate().toISOString() || post.date.toDate().toISOString() | |
}) | |
}) | |
return {path: 'meta.json', data: JSON.stringify(meta)} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment