refactor: remove portfolio
This commit is contained in:
parent
565297c9b3
commit
584b4a60da
54 changed files with 28 additions and 1085 deletions
|
@ -4,5 +4,4 @@ export const outPath = "./dist" // path to the json database
|
|||
export const contentDirectoryPath = `${outPath}/content`
|
||||
export const iconsDirectoryPath = `${outPath}/icons`
|
||||
export const mapFilePath = `${outPath}/map.json`
|
||||
export const portfolioFilePath = `${outPath}/portfolio.json`
|
||||
export const searchIndexFilePath = `${outPath}/search.json`
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
import fs from "fs"
|
||||
|
||||
import { mapFilePath, markdownPath, outPath, portfolioFilePath } from "./config"
|
||||
import { mapFilePath, markdownPath, outPath } from "./config"
|
||||
import { fillTags, parseSeries, sortDates } from "./postProcess"
|
||||
import { recursiveParse } from "./recursiveParse"
|
||||
import { saveIndex } from "./searchIndex"
|
||||
import type { ContentMap, PortfolioData, SeriesMap } from "./types/types"
|
||||
import type { ContentMap, SeriesMap } from "./types/types"
|
||||
import { ParseMode } from "./types/types"
|
||||
|
||||
export const contentMap: ContentMap = {
|
||||
|
@ -25,10 +25,6 @@ export const contentMap: ContentMap = {
|
|||
series: {},
|
||||
}
|
||||
export const seriesMap: SeriesMap = {}
|
||||
export const portfolioData: PortfolioData = {
|
||||
skills: new Set(),
|
||||
projects: {},
|
||||
}
|
||||
|
||||
async function main() {
|
||||
/**
|
||||
|
@ -60,7 +56,6 @@ async function main() {
|
|||
// parse markdown
|
||||
await recursiveParse(ParseMode.POSTS, markdownPath + "/posts")
|
||||
await recursiveParse(ParseMode.SERIES, markdownPath + "/series")
|
||||
await recursiveParse(ParseMode.PORTFOLIO, markdownPath + "/projects")
|
||||
|
||||
sortDates()
|
||||
fillTags()
|
||||
|
@ -71,14 +66,6 @@ async function main() {
|
|||
*/
|
||||
|
||||
fs.writeFileSync(mapFilePath, JSON.stringify(contentMap))
|
||||
fs.writeFileSync(
|
||||
portfolioFilePath,
|
||||
JSON.stringify({
|
||||
...portfolioData,
|
||||
skills: Array.from(portfolioData.skills),
|
||||
}),
|
||||
)
|
||||
|
||||
saveIndex()
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import supersub from "remark-supersub"
|
|||
import { unified } from "unified"
|
||||
|
||||
import type { MarkdownData } from "./types/types"
|
||||
import { ParseMode } from "./types/types"
|
||||
import { nthIndex } from "./util"
|
||||
|
||||
const processor = unified() // interface for remark and rehype
|
||||
|
@ -50,12 +49,10 @@ const processor = unified() // interface for remark and rehype
|
|||
*
|
||||
* @param {string} markdownRaw - raw unparsed text data of the markdown file
|
||||
* @param {string} path - filename of the markdown file
|
||||
* @param {ParseMode} mode
|
||||
*/
|
||||
export default async function parseMarkdown(
|
||||
markdownRaw: string,
|
||||
path: string,
|
||||
mode: ParseMode,
|
||||
): Promise<MarkdownData> {
|
||||
const fileHasFrontMatter = markdownRaw.startsWith("---")
|
||||
|
||||
|
@ -64,21 +61,11 @@ export default async function parseMarkdown(
|
|||
: {}
|
||||
|
||||
if (fileHasFrontMatter) {
|
||||
if (mode != ParseMode.PORTFOLIO) {
|
||||
if (!frontMatter.title)
|
||||
throw Error(`Title is not defined in file: ${path}`)
|
||||
if (!frontMatter.title)
|
||||
throw Error(`Title is not defined in file: ${path}`)
|
||||
|
||||
if (!frontMatter.date)
|
||||
throw Error(`Date is not defined in file: ${path}`)
|
||||
}
|
||||
|
||||
if (mode === ParseMode.PORTFOLIO) {
|
||||
if (frontMatter.overview) {
|
||||
frontMatter.overview = String(
|
||||
processor.processSync(frontMatter.overview),
|
||||
)
|
||||
}
|
||||
}
|
||||
if (!frontMatter.date)
|
||||
throw Error(`Date is not defined in file: ${path}`)
|
||||
}
|
||||
|
||||
frontMatter.content = touchupHTML(
|
||||
|
|
|
@ -5,7 +5,6 @@ import parseMarkdown from "../parseMarkdown"
|
|||
import { ParseMode } from "../types/types"
|
||||
import { path2FileOrFolderName, path2URL } from "../util"
|
||||
import parsePost from "./parsePost"
|
||||
import parseProjects from "./parseProjects"
|
||||
import parseSeries from "./parseSeries"
|
||||
|
||||
/**
|
||||
|
@ -98,9 +97,5 @@ async function parseFile(mode: ParseMode, path: string): Promise<void> {
|
|||
case ParseMode.SERIES:
|
||||
await parseSeries(dataToPass)
|
||||
break
|
||||
|
||||
case ParseMode.PORTFOLIO:
|
||||
await parseProjects(dataToPass)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
import type { SimpleIcon } from "simple-icons"
|
||||
import * as icons from "simple-icons"
|
||||
import tinycolor from "tinycolor2"
|
||||
|
||||
import { portfolioData } from ".."
|
||||
import { contentDirectoryPath, iconsDirectoryPath } from "../config"
|
||||
import { generateToc } from "../parseMarkdown"
|
||||
import { writeToFile } from "../util"
|
||||
import type { DataToPass } from "."
|
||||
|
||||
export default async function parseProjects({
|
||||
urlPath,
|
||||
markdownRaw,
|
||||
markdownData,
|
||||
}: DataToPass): Promise<void> {
|
||||
if (markdownData.badges) {
|
||||
;(markdownData.badges as string[]).forEach((slug) => {
|
||||
// todo: handle cases when icon is not on simple-icons
|
||||
const icon: SimpleIcon =
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
icons["si" + slug[0].toUpperCase() + slug.slice(1)]
|
||||
|
||||
portfolioData.skills.add(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,
|
||||
}),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// remove /projects/ prefix
|
||||
portfolioData.projects[urlPath.replace("/projects/", "")] = {
|
||||
name: markdownData.name as string,
|
||||
image: markdownData.image as string,
|
||||
overview: markdownData.overview as string,
|
||||
badges: (markdownData.badges as string[]) || [],
|
||||
repo: (markdownData.repo as string) || "",
|
||||
}
|
||||
|
||||
writeToFile(
|
||||
`${contentDirectoryPath}${urlPath}.json`,
|
||||
JSON.stringify({
|
||||
content: markdownData.content,
|
||||
toc: await generateToc(markdownRaw),
|
||||
}),
|
||||
)
|
||||
}
|
|
@ -32,7 +32,6 @@ export interface ContentMap {
|
|||
export enum ParseMode {
|
||||
POSTS,
|
||||
SERIES,
|
||||
PORTFOLIO,
|
||||
}
|
||||
|
||||
export interface MarkdownData {
|
||||
|
@ -67,13 +66,6 @@ export interface PageData {
|
|||
|
||||
order: string[]
|
||||
length: number
|
||||
|
||||
// portfolio
|
||||
|
||||
image: string // image url
|
||||
overview: string
|
||||
badges: string[]
|
||||
repo: string
|
||||
}
|
||||
|
||||
export interface Badge {
|
||||
|
@ -106,31 +98,3 @@ export interface SeriesEntry {
|
|||
index: number
|
||||
url: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Portfolio
|
||||
*/
|
||||
|
||||
export interface PortfolioData {
|
||||
// a set of valid simple icons slug
|
||||
skills: Set<string>
|
||||
|
||||
// key: url
|
||||
projects: {
|
||||
[key: string]: PortfolioProject
|
||||
}
|
||||
}
|
||||
|
||||
export interface PortfolioOverview {
|
||||
// link to my github
|
||||
github: string
|
||||
description: string
|
||||
}
|
||||
|
||||
export interface PortfolioProject {
|
||||
name: string
|
||||
image: string // url to the image
|
||||
overview: string
|
||||
badges: string[] // array of valid simpleIcons slug
|
||||
repo: string // url of the git repository
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue