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 { mapFilePath, markdownPath, portfolioFilePath } from "./config"
|
||||
import postProcess from "./postProcess"
|
||||
import {
|
||||
fillTags,
|
||||
generatePortfolioSVGs,
|
||||
parseSeries,
|
||||
sortDates,
|
||||
} from "./postProcess"
|
||||
import { recursiveParse } from "./recursiveParse"
|
||||
import { saveIndex } from "./searchIndex"
|
||||
import { ContentMap, ParseMode, PortfolioData, SeriesMap } from "./types/types"
|
||||
|
@ -55,15 +60,15 @@ if (!fs.lstatSync(markdownPath + "/series").isDirectory())
|
|||
* Parse
|
||||
*/
|
||||
|
||||
// parse markdown
|
||||
recursiveParse(ParseMode.POSTS, markdownPath + "/posts")
|
||||
recursiveParse(ParseMode.SERIES, markdownPath + "/series")
|
||||
recursiveParse(ParseMode.PORTFOLIO, markdownPath + "/projects")
|
||||
|
||||
/**
|
||||
* Post-process
|
||||
*/
|
||||
|
||||
postProcess()
|
||||
sortDates()
|
||||
fillTags()
|
||||
parseSeries()
|
||||
generatePortfolioSVGs()
|
||||
|
||||
/**
|
||||
* Save results
|
||||
|
|
|
@ -9,14 +9,7 @@ import skills from "./portfolio/skills.json"
|
|||
import { Badge } from "./types/types"
|
||||
import { writeToFile } from "./util"
|
||||
|
||||
export default function postProcess() {
|
||||
sortDates()
|
||||
fillTags()
|
||||
parseSeries()
|
||||
generatePortfolioSVGs()
|
||||
}
|
||||
|
||||
function sortDates() {
|
||||
export function sortDates() {
|
||||
const TmpDate = contentMap.date
|
||||
contentMap.date = {}
|
||||
Object.keys(TmpDate)
|
||||
|
@ -26,11 +19,11 @@ function sortDates() {
|
|||
})
|
||||
}
|
||||
|
||||
function fillTags() {
|
||||
export function fillTags() {
|
||||
contentMap.meta.tags = Object.keys(contentMap.tags)
|
||||
}
|
||||
|
||||
function parseSeries() {
|
||||
export function parseSeries() {
|
||||
// sort series map
|
||||
for (const seriesURL in seriesMap) {
|
||||
seriesMap[seriesURL].sort((a, b) => {
|
||||
|
@ -50,7 +43,7 @@ function parseSeries() {
|
|||
}
|
||||
}
|
||||
|
||||
function generatePortfolioSVGs() {
|
||||
export function generatePortfolioSVGs() {
|
||||
/**
|
||||
* render skills.svg
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue