Skip to content

Commit a9ca440

Browse files
committed
feat: add placeholder index.md for each language
1 parent 28bc76e commit a9ca440

42 files changed

Lines changed: 571 additions & 169 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vitepress/config.mts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import { dirname, resolve } from 'node:path'
66
import {
77
buildLocaleRedirectScript,
88
DEFAULT_WIKI_LOCALE,
9-
getWikiContentLocales,
10-
resolveContentLocale,
119
WIKI_UI_LOCALES,
1210
} from '../ci/lib/tfg-locale.mjs'
1311
import { buildVitePressBootstrapScript } from '../ci/lib/tfg-theme.mjs'
1412
import { assertUiLocales, buildSearchOptions, buildThemeConfig, loadUiLocales } from './i18n/index.ts'
13+
import { homeEditLinkPlugin } from './plugins/home-edit-link.mts'
1514
import {
1615
buildPageSeoHead,
1716
buildWebSiteJsonLd,
@@ -23,8 +22,6 @@ const __dirname = dirname(fileURLToPath(import.meta.url))
2322
const GITHUB_ORG = 'TerraFirmaGreg-Team'
2423
const GITHUB_REPO = `${GITHUB_ORG}/Wiki`
2524
const NAMESPACE = 'modern'
26-
const DOCS_ROOT = resolve(__dirname, '..', 'docs')
27-
const CONTENT_LOCALES = getWikiContentLocales(DOCS_ROOT)
2825
const SITE_DOMAIN = readFileSync(resolve(__dirname, '..', 'public', 'CNAME'), 'utf8').trim()
2926
const SITE_URL = `https://${SITE_DOMAIN}`
3027
const OG_IMAGE = `${SITE_URL}/logo.png`
@@ -44,10 +41,9 @@ function localeBase(locale: Locale) {
4441
}
4542

4643
function sidebarOptions(locale: Locale): VitePressSidebarOptions {
47-
const contentLocale = resolveContentLocale(locale, CONTENT_LOCALES)
4844
return {
4945
documentRootPath: '/docs',
50-
scanStartPath: `${NAMESPACE}/${contentLocale}`,
46+
scanStartPath: `${NAMESPACE}/${locale}`,
5147
resolvePath: `${localeBase(locale)}/`,
5248
collapsed: false,
5349
useTitleFromFrontmatter: true,
@@ -81,8 +77,8 @@ export default defineConfig(
8177
publicDir: resolve(__dirname, '..', 'public'),
8278
define: {
8379
'import.meta.env.VITE_EXTRA_EXTENSIONS': JSON.stringify('html'),
84-
__WIKI_CONTENT_LOCALES__: JSON.stringify(CONTENT_LOCALES),
8580
},
81+
plugins: [homeEditLinkPlugin(resolve(__dirname, '..', 'docs'), UI, GITHUB_REPO)],
8682
},
8783
title: SITE_TITLE,
8884
description: SITE_DESCRIPTION,
@@ -112,7 +108,7 @@ export default defineConfig(
112108
transformHead({ page, title, description }) {
113109
const head = buildPageSeoHead(SITE_URL, page, title, description, OG_IMAGE)
114110
if (page === 'index.md') {
115-
head.push(['script', {}, buildLocaleRedirectScript(CONTENT_LOCALES)])
111+
head.push(['script', {}, buildLocaleRedirectScript()])
116112
}
117113
return head
118114
},

.vitepress/i18n/de_de.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"sidebarMenuLabel": "Menu",
2323
"returnToTopLabel": "Back to top",
2424
"langMenuLabel": "Change language",
25+
"notFound": {
26+
"title": "PAGE NOT FOUND",
27+
"quote": "This page does not exist, or it has not been translated into your language yet.",
28+
"homeLink": "Take me home"
29+
},
2530
"search": {
2631
"button": {
2732
"buttonText": "Search",

.vitepress/i18n/en_us.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"sidebarMenuLabel": "Menu",
2323
"returnToTopLabel": "Back to top",
2424
"langMenuLabel": "Change language",
25+
"notFound": {
26+
"title": "PAGE NOT FOUND",
27+
"quote": "This page does not exist, or it has not been translated into your language yet.",
28+
"homeLink": "Take me home"
29+
},
2530
"search": {
2631
"button": {
2732
"buttonText": "Search",

.vitepress/i18n/es_es.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"sidebarMenuLabel": "Menu",
2323
"returnToTopLabel": "Back to top",
2424
"langMenuLabel": "Change language",
25+
"notFound": {
26+
"title": "PAGE NOT FOUND",
27+
"quote": "This page does not exist, or it has not been translated into your language yet.",
28+
"homeLink": "Take me home"
29+
},
2530
"search": {
2631
"button": {
2732
"buttonText": "Search",

.vitepress/i18n/fr_fr.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"sidebarMenuLabel": "Menu",
2323
"returnToTopLabel": "Back to top",
2424
"langMenuLabel": "Change language",
25+
"notFound": {
26+
"title": "PAGE NOT FOUND",
27+
"quote": "This page does not exist, or it has not been translated into your language yet.",
28+
"homeLink": "Take me home"
29+
},
2530
"search": {
2631
"button": {
2732
"buttonText": "Search",

.vitepress/i18n/hu_hu.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"sidebarMenuLabel": "Menu",
2323
"returnToTopLabel": "Back to top",
2424
"langMenuLabel": "Change language",
25+
"notFound": {
26+
"title": "PAGE NOT FOUND",
27+
"quote": "This page does not exist, or it has not been translated into your language yet.",
28+
"homeLink": "Take me home"
29+
},
2530
"search": {
2631
"button": {
2732
"buttonText": "Search",

.vitepress/i18n/index.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ export type UiSearchTranslations = {
3939
}
4040
}
4141

42+
export type UiNotFoundLabels = {
43+
title: string
44+
quote: string
45+
homeLink: string
46+
}
47+
4248
export type UiLocale = {
4349
label: string
4450
lang: string
@@ -51,6 +57,7 @@ export type UiLocale = {
5157
sidebarMenuLabel: string
5258
returnToTopLabel: string
5359
langMenuLabel: string
60+
notFound: UiNotFoundLabels
5461
search: UiSearchTranslations
5562
}
5663

@@ -129,6 +136,12 @@ export function buildThemeConfig(
129136
sidebarMenuLabel: ui.sidebarMenuLabel,
130137
returnToTopLabel: ui.returnToTopLabel,
131138
langMenuLabel: ui.langMenuLabel,
139+
notFound: {
140+
title: ui.notFound.title,
141+
quote: ui.notFound.quote,
142+
linkText: ui.notFound.homeLink,
143+
linkLabel: ui.notFound.homeLink,
144+
},
132145
}
133146
}
134147

@@ -159,3 +172,25 @@ export function assertUiLocales(locales: readonly string[]) {
159172
}
160173
}
161174
}
175+
176+
const HOME_INDEX_RE = /^modern\/([^/]+)\/index\.md$/
177+
178+
export function homeEditLinkSuffix(
179+
relativePath: string,
180+
ui: Record<string, UiLocale>,
181+
githubRepo: string,
182+
): string | null {
183+
const match = relativePath.match(HOME_INDEX_RE)
184+
if (!match) {
185+
return null
186+
}
187+
188+
const locale = match[1]
189+
const labels = ui[locale]
190+
if (!labels?.editLink) {
191+
return null
192+
}
193+
194+
const url = `https://github.com/${githubRepo}/edit/main/docs/${relativePath}`
195+
return `\n\n[${labels.editLink}](${url})\n`
196+
}

.vitepress/i18n/ja_jp.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"sidebarMenuLabel": "Menu",
2323
"returnToTopLabel": "Back to top",
2424
"langMenuLabel": "Change language",
25+
"notFound": {
26+
"title": "PAGE NOT FOUND",
27+
"quote": "This page does not exist, or it has not been translated into your language yet.",
28+
"homeLink": "Take me home"
29+
},
2530
"search": {
2631
"button": {
2732
"buttonText": "Search",

.vitepress/i18n/ko_kr.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"sidebarMenuLabel": "Menu",
2323
"returnToTopLabel": "Back to top",
2424
"langMenuLabel": "Change language",
25+
"notFound": {
26+
"title": "PAGE NOT FOUND",
27+
"quote": "This page does not exist, or it has not been translated into your language yet.",
28+
"homeLink": "Take me home"
29+
},
2530
"search": {
2631
"button": {
2732
"buttonText": "Search",

.vitepress/i18n/pl_pl.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"sidebarMenuLabel": "Menu",
2323
"returnToTopLabel": "Back to top",
2424
"langMenuLabel": "Change language",
25+
"notFound": {
26+
"title": "PAGE NOT FOUND",
27+
"quote": "This page does not exist, or it has not been translated into your language yet.",
28+
"homeLink": "Take me home"
29+
},
2530
"search": {
2631
"button": {
2732
"buttonText": "Search",

0 commit comments

Comments
 (0)