Skip to content

Commit

Permalink
fix(query-posts): expose categoriesInfo and tagsInfo on pagePublicFields
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Jun 4, 2020
1 parent 92bf64f commit 915f322
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/saber-plugin-query-posts/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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
Expand Down

1 comment on commit 915f322

@vercel
Copy link

@vercel vercel bot commented on 915f322 Jun 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.