Merge pull request #701 from rareyesdev/fix/include-drafts-in-tag-data-during-development

fix: include drafts in tag data during development
This commit is contained in:
Timothy 2023-08-28 10:46:17 +08:00 committed by GitHub
commit cc4e17d5b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,6 +23,7 @@ import siteMetadata from './data/siteMetadata'
import { allCoreContent, sortPosts } from 'pliny/utils/contentlayer.js'
const root = process.cwd()
const isProduction = process.env.NODE_ENV === 'production'
const computedFields: ComputedFields = {
readingTime: { type: 'json', resolve: (doc) => readingTime(doc.body.raw) },
@ -47,7 +48,7 @@ const computedFields: ComputedFields = {
function createTagCount(allBlogs) {
const tagCount: Record<string, number> = {}
allBlogs.forEach((file) => {
if (file.tags && file.draft !== true) {
if (file.tags && (!isProduction || file.draft !== true)) {
file.tags.forEach((tag) => {
const formattedTag = GithubSlugger.slug(tag)
if (formattedTag in tagCount) {