refactor: improve code readability
This commit is contained in:
parent
335c23ad9c
commit
4a6cb553f5
2 changed files with 15 additions and 17 deletions
|
@ -9,7 +9,12 @@
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
|
|
||||||
import { mapFilePath, markdownPath, portfolioFilePath } from "./config"
|
import { mapFilePath, markdownPath, portfolioFilePath } from "./config"
|
||||||
import postProcess from "./postProcess"
|
import {
|
||||||
|
fillTags,
|
||||||
|
generatePortfolioSVGs,
|
||||||
|
parseSeries,
|
||||||
|
sortDates,
|
||||||
|
} from "./postProcess"
|
||||||
import { recursiveParse } from "./recursiveParse"
|
import { recursiveParse } from "./recursiveParse"
|
||||||
import { saveIndex } from "./searchIndex"
|
import { saveIndex } from "./searchIndex"
|
||||||
import { ContentMap, ParseMode, PortfolioData, SeriesMap } from "./types/types"
|
import { ContentMap, ParseMode, PortfolioData, SeriesMap } from "./types/types"
|
||||||
|
@ -55,15 +60,15 @@ if (!fs.lstatSync(markdownPath + "/series").isDirectory())
|
||||||
* Parse
|
* Parse
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// parse markdown
|
||||||
recursiveParse(ParseMode.POSTS, markdownPath + "/posts")
|
recursiveParse(ParseMode.POSTS, markdownPath + "/posts")
|
||||||
recursiveParse(ParseMode.SERIES, markdownPath + "/series")
|
recursiveParse(ParseMode.SERIES, markdownPath + "/series")
|
||||||
recursiveParse(ParseMode.PORTFOLIO, markdownPath + "/projects")
|
recursiveParse(ParseMode.PORTFOLIO, markdownPath + "/projects")
|
||||||
|
|
||||||
/**
|
sortDates()
|
||||||
* Post-process
|
fillTags()
|
||||||
*/
|
parseSeries()
|
||||||
|
generatePortfolioSVGs()
|
||||||
postProcess()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save results
|
* Save results
|
||||||
|
|
|
@ -9,14 +9,7 @@ import skills from "./portfolio/skills.json"
|
||||||
import { Badge } from "./types/types"
|
import { Badge } from "./types/types"
|
||||||
import { writeToFile } from "./util"
|
import { writeToFile } from "./util"
|
||||||
|
|
||||||
export default function postProcess() {
|
export function sortDates() {
|
||||||
sortDates()
|
|
||||||
fillTags()
|
|
||||||
parseSeries()
|
|
||||||
generatePortfolioSVGs()
|
|
||||||
}
|
|
||||||
|
|
||||||
function sortDates() {
|
|
||||||
const TmpDate = contentMap.date
|
const TmpDate = contentMap.date
|
||||||
contentMap.date = {}
|
contentMap.date = {}
|
||||||
Object.keys(TmpDate)
|
Object.keys(TmpDate)
|
||||||
|
@ -26,11 +19,11 @@ function sortDates() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillTags() {
|
export function fillTags() {
|
||||||
contentMap.meta.tags = Object.keys(contentMap.tags)
|
contentMap.meta.tags = Object.keys(contentMap.tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseSeries() {
|
export function parseSeries() {
|
||||||
// sort series map
|
// sort series map
|
||||||
for (const seriesURL in seriesMap) {
|
for (const seriesURL in seriesMap) {
|
||||||
seriesMap[seriesURL].sort((a, b) => {
|
seriesMap[seriesURL].sort((a, b) => {
|
||||||
|
@ -50,7 +43,7 @@ function parseSeries() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function generatePortfolioSVGs() {
|
export function generatePortfolioSVGs() {
|
||||||
/**
|
/**
|
||||||
* render skills.svg
|
* render skills.svg
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue