1
1
mirror of https://github.com/theoludwig/theoludwig.git synced 2025-05-29 22:37:44 +02:00

feat(posts): add mistakes-as-junior-developer

This commit is contained in:
Divlo
2022-03-14 09:09:46 +01:00
parent 94212f9b5c
commit 919ebd5f3e
15 changed files with 1820 additions and 9004 deletions

View File

@ -1,22 +1,22 @@
const path = require('path')
const fs = require('fs')
import fs from 'fs'
import { fileURLToPath } from 'url'
const ejs = require('ejs')
const date = require('date-and-time')
const { Parcel } = require('@parcel/core')
import ejs from 'ejs'
import date from 'date-and-time'
import { Parcel } from '@parcel/core'
const render = async (resume) => {
const themeIndexPath = path.join(__dirname, 'theme', 'index.ejs')
const themeBuildPath = path.join(__dirname, 'theme', 'index.html')
const indexHTMLPath = path.join(__dirname, 'dist', 'index.html')
const html = await ejs.renderFile(themeIndexPath, {
export const render = async (resume) => {
const themeIndexURL = new URL('./theme/index.ejs', import.meta.url)
const themeBuildURL = new URL('./theme/index.html', import.meta.url)
const indexHTMLURL = new URL('./dist/index.html', import.meta.url)
const themeBuildPath = fileURLToPath(themeBuildURL)
const html = await ejs.renderFile(fileURLToPath(themeIndexURL), {
date,
locals: {
...resume
}
})
await fs.promises.writeFile(themeBuildPath, html, { encoding: 'utf-8' })
await fs.promises.writeFile(themeBuildURL, html, { encoding: 'utf-8' })
const bundler = new Parcel({
entries: themeBuildPath,
source: themeBuildPath,
@ -24,9 +24,5 @@ const render = async (resume) => {
defaultConfig: '@parcel/config-default'
})
await bundler.run()
return await fs.promises.readFile(indexHTMLPath, { encoding: 'utf-8' })
}
module.exports = {
render
return await fs.promises.readFile(indexHTMLURL, { encoding: 'utf-8' })
}

File diff suppressed because it is too large Load Diff

View File

@ -2,9 +2,10 @@
"name": "jsonresume-theme-custom",
"private": true,
"version": "1.0.0",
"type": "module",
"scripts": {},
"dependencies": {
"date-and-time": "2.1.2",
"date-and-time": "2.3.0",
"ejs": "3.1.6",
"modern-normalize": "1.1.0"
},

View File

@ -0,0 +1,18 @@
import fs from 'fs'
import { render } from '../index.js'
const jsonResumeURL = new URL('../../resume.json', import.meta.url)
const publicResumeURL = new URL(
'../../public/curriculum-vitae.html',
import.meta.url
)
const dataResumeStringJSON = await fs.promises.readFile(jsonResumeURL, {
encoding: 'utf-8'
})
const dataResumeJSON = JSON.parse(dataResumeStringJSON)
const dataResumeIndexHTML = await render(dataResumeJSON)
await fs.promises.writeFile(publicResumeURL, dataResumeIndexHTML, {
encoding: 'utf-8'
})