restructure project to use turborepo
This commit is contained in:
parent
670ab793da
commit
90c535ebb2
181 changed files with 18477 additions and 10909 deletions
74
apps/blog/generate/recursiveParse/parsePortfolio.ts
Normal file
74
apps/blog/generate/recursiveParse/parsePortfolio.ts
Normal file
|
@ -0,0 +1,74 @@
|
|||
import tinycolor from "tinycolor2"
|
||||
|
||||
import { contentDirectoryPath, iconsDirectoryPath } from "../config"
|
||||
import { generateToc } from "../parseMarkdown"
|
||||
import { writeToFile } from "../util"
|
||||
import { portfolioData } from ".."
|
||||
import { DataToPass } from "."
|
||||
|
||||
export default function parsePortfolio(data: DataToPass): void {
|
||||
const { urlPath, markdownRaw, markdownData } = data
|
||||
|
||||
if (urlPath.endsWith(".kr")) {
|
||||
const contentID = urlPath.slice(0, urlPath.length - 3)
|
||||
|
||||
if (portfolioData.projects[contentID]) {
|
||||
portfolioData.projects[contentID] = {
|
||||
...portfolioData.projects[contentID],
|
||||
overview_kr: markdownData.overview as string,
|
||||
}
|
||||
} else {
|
||||
portfolioData.projects[contentID] = {
|
||||
name: "",
|
||||
image: "",
|
||||
overview_en: "",
|
||||
overview_kr: markdownData.overview as string,
|
||||
badges: [],
|
||||
repo: "",
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (markdownData.badges) {
|
||||
;(markdownData.badges as string[]).forEach((slug) => {
|
||||
// todo: handle cases when icon is not on simple-icons
|
||||
|
||||
portfolioData.skills.add(slug)
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const icon = require("simple-icons")[slug]
|
||||
|
||||
const color = tinycolor(icon.hex).lighten(5).desaturate(5)
|
||||
|
||||
// save svg icon
|
||||
writeToFile(
|
||||
`${iconsDirectoryPath}/${icon.slug}.json`,
|
||||
JSON.stringify({
|
||||
svg: icon.svg,
|
||||
hex: color.toHexString(),
|
||||
isDark: color.isDark(),
|
||||
title: icon.title,
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
portfolioData.projects[urlPath] = {
|
||||
name: markdownData.name as string,
|
||||
image: markdownData.image as string,
|
||||
overview_en: markdownData.overview as string,
|
||||
overview_kr: portfolioData.projects[urlPath]
|
||||
? portfolioData.projects[urlPath].overview_kr
|
||||
: "",
|
||||
badges: (markdownData.badges as string[]) || [],
|
||||
repo: (markdownData.repo as string) || "",
|
||||
}
|
||||
}
|
||||
|
||||
writeToFile(
|
||||
`${contentDirectoryPath}${urlPath}.json`,
|
||||
JSON.stringify({
|
||||
content: markdownData.content,
|
||||
toc: generateToc(markdownRaw),
|
||||
})
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue