feat(directory): add changelogs page

This commit is contained in:
Haoyu Xu
2023-03-01 16:22:35 -05:00
parent 3cc0f48648
commit 1c8356bbbb
29 changed files with 1077 additions and 397 deletions

View File

@@ -16,8 +16,12 @@ const NICKNAME = {
"zh_TW": "博士",
}
export function getOperatorId(operatorConfig) {
return operatorConfig.filename.replace(/^(dyn_illust_)(char_[\d]+)(_[\w]+)(|(_.+))$/g, '$2$3$4')
}
export default class CharwordTable {
#operatorIDs = Object.values(__config.operators).map(operator => { return this.#getOperatorId(operator) })
#operatorIDs = Object.values(__config.operators).map(operator => { return getOperatorId(operator) })
#charwordTablePath = path.join(__projetRoot, __config.folder.operator, __config.folder.share)
#charwordTableFile = path.join(this.#charwordTablePath, 'charword_table.json')
#charwordTable = JSON.parse(readSync(this.#charwordTableFile)) || {
@@ -43,7 +47,7 @@ export default class CharwordTable {
}
lookup(operatorName) {
const operatorId = this.#getOperatorId(__config.operators[operatorName])
const operatorId = getOperatorId(__config.operators[operatorName])
const operatorBlock = this.#charwordTable.operators[operatorId]
return {
config: this.#charwordTable.config,
@@ -51,10 +55,6 @@ export default class CharwordTable {
}
}
#getOperatorId(operatorConfig) {
return operatorConfig.filename.replace(/^(dyn_illust_)(char_[\d]+)(_[\w]+)(|(_.+))$/g, '$2$3$4')
}
async #load(region) {
if (region === 'zh_TW') {
return await this.#zhTWLoad()

View File

@@ -1,6 +1,7 @@
import path from 'path'
import { read } from './yaml.js'
import { read as readVersion } from './version.js'
import { getOperatorId } from './charword_table.js'
export default function () {
return process(read(path.join(__projetRoot, 'config.yaml')))
@@ -15,6 +16,9 @@ function process(config) {
// add link
operator.link = operatorName
// id
operator.id = getOperatorId(operator).replace(/^(char_)(\d+)(_.+)$/g, '$2')
}
// version

View File

@@ -1,5 +1,6 @@
import path from 'path'
import { writeSync, copy, rmdir } from './file.js'
import { read } from './yaml.js';
/**
* TODO:
@@ -26,8 +27,24 @@ export default function () {
.sort((a, b) => Date.parse(b[0].date) - Date.parse(a[0].date)),
}
const versionJson = __config.version
const changelogs = read(path.join(__projetRoot, 'changelogs.yaml'))
const changelogsArray = Object.keys(changelogs).reduce((acc, cur) => {
const array = []
Object.keys(changelogs[cur]).map((item) => {
array.push({
key: cur,
date: item,
content: [...changelogs[cur][item]]
})
})
acc.push(array)
return acc
}, [])
writeSync(JSON.stringify(directoryJson, null), path.join(targetFolder, "directory.json"))
writeSync(JSON.stringify(versionJson, null), path.join(targetFolder, "version.json"))
writeSync(JSON.stringify(changelogsArray, null), path.join(targetFolder, "changelogs.json"))
filesToCopy.forEach((key) => {
copy(path.join(sourceFolder, key, 'assets.json'), path.join(targetFolder, `${__config.operators[key].filename}.json`))
})