-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added workflow. Removed srver dependant features
- Loading branch information
Showing
6 changed files
with
53 additions
and
19 deletions.
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"markdown":3,"code":3,"features":3,"next-js":5,"math":1,"ols":1,"github":1,"guide":4,"tailwind":2,"holiday":1,"canada":1,"images":1,"writings":1,"book":1,"reflection":1,"multi-author":1,"feature":1} | ||
{} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { writeFileSync } from 'fs' | ||
import GithubSlugger from 'github-slugger' | ||
import { allCoreContent, sortPosts } from 'pliny/utils/contentlayer.js' | ||
import { allBlogs } from '../.contentlayer/generated/index.mjs' | ||
import siteMetadata from '../data/siteMetadata.js' | ||
|
||
const isProduction = process.env.NODE_ENV === 'production' | ||
|
||
/** | ||
* Count the occurrences of all tags across blog posts and write to json file | ||
*/ | ||
export async function createTagCount() { | ||
const tagCount = {} | ||
allBlogs.forEach((file) => { | ||
if (file.tags && (!isProduction || file.draft !== true)) { | ||
file.tags.forEach((tag) => { | ||
const formattedTag = GithubSlugger.slug(tag) | ||
if (formattedTag in tagCount) { | ||
tagCount[formattedTag] += 1 | ||
} else { | ||
tagCount[formattedTag] = 1 | ||
} | ||
}) | ||
} | ||
}) | ||
writeFileSync('./app/tag-data.json', JSON.stringify(tagCount)) | ||
} | ||
|
||
export async function createSearchIndex() { | ||
if ( | ||
siteMetadata?.search?.provider === 'kbar' && | ||
siteMetadata.search.kbarConfig.searchDocumentsPath | ||
) { | ||
writeFileSync( | ||
`public/${siteMetadata.search.kbarConfig.searchDocumentsPath}`, | ||
JSON.stringify(allCoreContent(sortPosts(allBlogs))) | ||
) | ||
console.log('Local search index generated...') | ||
} | ||
} | ||
|
||
async function postContentlayer() { | ||
await createTagCount() | ||
await createSearchIndex() | ||
} | ||
|
||
postContentlayer() |