Use mcmeta (#197)

* Simplify data fetching by using mcmeta

* Fetch sounds from mcmeta
This commit is contained in:
Misode
2022-01-28 01:25:10 +01:00
committed by GitHub
parent ec432288e7
commit 623e38d98c
9 changed files with 85 additions and 672 deletions
+10 -15
View File
@@ -1,9 +1,9 @@
import { defineConfig } from 'vite'
import preact from '@preact/preset-vite'
import html from '@rollup/plugin-html'
import config from './src/config.json'
import { env } from 'process'
import copy from 'rollup-plugin-copy'
import { defineConfig } from 'vite'
import config from './src/config.json'
import English from './src/locales/en.json'
export default defineConfig({
@@ -12,27 +12,27 @@ export default defineConfig({
rollupOptions: {
plugins: [
html({
fileName: `404.html`,
fileName: '404.html',
title: '404',
template: template,
}),
html({
fileName: `sounds/index.html`,
fileName: 'sounds/index.html',
title: getTitle({ id: 'title.sounds', page: true }),
template: template,
}),
html({
fileName: `changelog/index.html`,
fileName: 'changelog/index.html',
title: getTitle({ id: 'title.changelog', page: true }),
template: template,
}),
html({
fileName: `worldgen/index.html`,
fileName: 'worldgen/index.html',
title: getTitle({ id: 'worldgen', category: true }),
template: template,
}),
html({
fileName: `assets/index.html`,
fileName: 'assets/index.html',
title: getTitle({ id: 'assets', category: true }),
template: template,
}),
@@ -46,8 +46,8 @@ export default defineConfig({
{ src: 'src/sitemap.txt', dest: 'dist' },
{ src: 'src/sitemap.txt', dest: 'dist', rename: 'sitemap2.txt' },
],
hook: 'writeBundle'
})
hook: 'writeBundle',
}),
],
},
},
@@ -55,8 +55,7 @@ export default defineConfig({
stringify: true,
},
define: {
__MCDATA_MASTER_HASH__: env.mcdata_hash,
__VANILLA_DATAPACK_SUMMARY_HASH__: env.vanilla_datapack_summary_hash,
__LATEST_VERSION__: env.latest_version,
},
plugins: [preact()],
})
@@ -68,10 +67,6 @@ function getTitle(m) {
return `${English[m.id] ?? ''}${m.page ? '' : ` Generator${m.category === true ? 's' : ''}`} Minecraft ${versions.join(', ')}`
}
function getTitleSuffix(versions ) {
}
function template({ files, title }) {
const source = files.html.find(f => f.fileName === 'index.html').source
return source.replace(/<title>.*<\/title>/, `<title>${title}</title>`)