mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-30 17:49:34 +00:00
Improve Minecraft versions in title
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
</script>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Data Pack Generators Minecraft 1.18, 1.18.2, 1.19</title>
|
||||
<title>Data Pack Generators - Minecraft 1.17, 1.18, 1.19</title>
|
||||
<link rel="icon" href="/src/favicon-32.png" sizes="32x32">
|
||||
<script async src="https://media.ethicalads.io/media/client/ethicalads.min.js"></script>
|
||||
<script>
|
||||
|
||||
@@ -40,7 +40,9 @@ export function TitleProvider({ children }: { children: ComponentChildren }) {
|
||||
titleSuffix = ` - ${suffix}`
|
||||
}
|
||||
if (!(versionIds?.length === 0)) {
|
||||
const titleVersions = versions.map(v => v.id).slice(-VERSIONS_IN_TITLE)
|
||||
const titleVersions = versions.map(v => v.id)
|
||||
.filter((v, _, arr) => v.length === 4 || arr.length <= 3)
|
||||
.slice(-VERSIONS_IN_TITLE)
|
||||
titleSuffix = ` - Minecraft ${titleVersions.join(', ')}`
|
||||
}
|
||||
document.title = title + titleSuffix
|
||||
|
||||
@@ -3,12 +3,10 @@ import html from '@rollup/plugin-html'
|
||||
import glob from 'fast-glob'
|
||||
import fs from 'fs'
|
||||
import yaml from 'js-yaml'
|
||||
import { createRequire } from 'module'
|
||||
import { env } from 'process'
|
||||
import { visualizer } from 'rollup-plugin-visualizer'
|
||||
import { defineConfig } from 'vite'
|
||||
import { viteStaticCopy } from 'vite-plugin-static-copy'
|
||||
const require = createRequire(import.meta.url)
|
||||
const config = require('./src/config.json')
|
||||
const English = require('./src/locales/en.json')
|
||||
|
||||
@@ -49,19 +47,14 @@ export default defineConfig({
|
||||
title: '404',
|
||||
template,
|
||||
}),
|
||||
...['sounds', 'changelog', 'versions', 'guides'].map(id => html({
|
||||
...['generators', 'worldgen', 'partners', 'sounds', 'changelog', 'versions', 'guides'].map(id => html({
|
||||
fileName: `${id}/index.html`,
|
||||
title: getTitle({ id: `title.${id}`, page: true }),
|
||||
template,
|
||||
})),
|
||||
...['worldgen', 'assets'].map(id => html({
|
||||
fileName: `${id}/index.html`,
|
||||
title: getTitle({ id, category: true }),
|
||||
title: `${English[`title.${id}`] ?? ''} - ${getVersions()}`,
|
||||
template,
|
||||
})),
|
||||
...config.generators.map(m => html({
|
||||
fileName: `${m.url}/index.html`,
|
||||
title: getTitle(m),
|
||||
title: `${English[m.id] ?? ''} Generator${m.category === true ? 's' : ''} - ${getVersions(m)}`,
|
||||
template,
|
||||
})),
|
||||
...guides.map(g => {
|
||||
@@ -108,11 +101,15 @@ export default defineConfig({
|
||||
],
|
||||
})
|
||||
|
||||
function getTitle(m) {
|
||||
const minVersion = Math.max(0, config.versions.findIndex(v => m.minVersion === v.id))
|
||||
const versions = config.versions.slice(minVersion).map(v => v.id)
|
||||
versions.splice(0, versions.length - 3)
|
||||
return `${English[m.id] ?? ''}${m.page ? '' : ` Generator${m.category === true ? 's' : ''}`} - Minecraft ${versions.join(', ')}`
|
||||
function getVersions(m) {
|
||||
const minVersion = Math.max(0, config.versions.findIndex(v => m?.minVersion === v.id))
|
||||
const maxVersion = config.versions.findIndex(v => m?.maxVersion === v.id)
|
||||
const versions = config.versions
|
||||
.filter((_, i) => minVersion <= i && (maxVersion === -1 || i <= maxVersion))
|
||||
.map(v => v.id)
|
||||
.filter((v, _, arr) => v.length === 4 || arr.length <= 3)
|
||||
.slice(-3)
|
||||
return `Minecraft ${versions.join(', ')}`
|
||||
}
|
||||
|
||||
function template({ files, title }) {
|
||||
|
||||
Reference in New Issue
Block a user