From a36be09d247bf909f6c6df7e5751ad49a7b01ddc Mon Sep 17 00:00:00 2001 From: curben <2809763-curben@users.noreply.gitlab.com> Date: Mon, 26 Aug 2019 20:52:24 +0930 Subject: [PATCH] feat(listTags): drop listTags in favor of official list_tags - Hexo has added microformat and schema * https://github.com/hexojs/hexo/pull/3678 --- scripts/listTags.js | 73 ---------------------- themes/typing/layout/_partial/post/tag.ejs | 2 +- 2 files changed, 1 insertion(+), 74 deletions(-) delete mode 100644 scripts/listTags.js diff --git a/scripts/listTags.js b/scripts/listTags.js deleted file mode 100644 index 0145be4..0000000 --- a/scripts/listTags.js +++ /dev/null @@ -1,73 +0,0 @@ -'use strict' -/* global hexo */ - -/* -* Modified from the hexo version, -* https://github.com/hexojs/hexo/blob/master/lib/plugins/helper/list_tags.js -* to add rel="tag" -* http://microformats.org/wiki/rel-tag -*/ - -function listTagsHelper (tags, options) { - if (!options && (!tags || !Object.prototype.hasOwnProperty.call(tags, 'length'))) { - options = tags - tags = this.site.tags - } - - if (!tags || !tags.length) return '' - options = options || {} - - const { style = 'list', transform, separator = ', ', suffix = '' } = options - const showCount = Object.prototype.hasOwnProperty.call(options, 'show_count') ? options.show_count : true - const className = options.class || 'tag' - const orderby = options.orderby || 'name' - const order = options.order || 1 - let result = '' - const self = this - - // Sort the tags - tags = tags.sort(orderby, order) - - // Ignore tags with zero posts - tags = tags.filter(tag => tag.length) - - // Limit the number of tags - if (options.amount) tags = tags.limit(options.amount) - - if (style === 'list') { - result += `' - } else { - tags.forEach((tag, i) => { - if (i) result += separator - - result += `' - }) - } - - return result -} - -hexo.extend.helper.register('listTags', listTagsHelper) diff --git a/themes/typing/layout/_partial/post/tag.ejs b/themes/typing/layout/_partial/post/tag.ejs index 646faa5..9937c99 100644 --- a/themes/typing/layout/_partial/post/tag.ejs +++ b/themes/typing/layout/_partial/post/tag.ejs @@ -1,5 +1,5 @@ <% if (post.tags && post.tags.length) { %> - <%- listTags(post.tags, { + <%- list_tags(post.tags, { show_count: false, class: 'article-tag', transform: titlecase