From 915f3226c4efdbfef435f62d5bd71681eb67b1c1 Mon Sep 17 00:00:00 2001 From: EGOIST <0x142857@gmail.com> Date: Thu, 4 Jun 2020 13:36:01 +0800 Subject: [PATCH] fix(query-posts): expose categoriesInfo and tagsInfo on pagePublicFields --- packages/saber-plugin-query-posts/lib/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/saber-plugin-query-posts/lib/index.js b/packages/saber-plugin-query-posts/lib/index.js index fd5496d86..7a3b0b89d 100644 --- a/packages/saber-plugin-query-posts/lib/index.js +++ b/packages/saber-plugin-query-posts/lib/index.js @@ -72,7 +72,7 @@ exports.apply = (api, options = {}) => { // Group posts for tag pages const tags = [].concat(page.tags || []) if (tags.length > 0) { - page.tagsInfo = [] + page.tagsInfo = pagePublicFields.tagsInfo = [] for (const tag of tags) { const tagSlug = getIdFromMap(tagsMap, tag) page.tagsInfo.push({ @@ -94,7 +94,10 @@ exports.apply = (api, options = {}) => { .map(v => (Array.isArray(v) ? v : v.split('/'))) if (categories.length > 0) { - page.categoriesInfo = [] + // TODO: exposing a function for getting category/tag info in the future + // e.g. getCategoryInfo(categoryName) + // returns `{ permalink: string, slug: string }` + page.categoriesInfo = pagePublicFields.categoriesInfo = [] for (const category of categories) { for (const index of category.keys()) { const categorySlug = category