Merge pull request #4600 from eriese/eriese-pb-nav
fix (prebuild) fix dev and lab prebuild, nav prebuild translations
This commit is contained in:
commit
54fe3c9fdb
7 changed files with 26 additions and 19 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -38,7 +38,7 @@ packages/new-design/lib/banner.mjs
|
||||||
|
|
||||||
# Lab auto-generated content
|
# Lab auto-generated content
|
||||||
sites/lab/lib
|
sites/lab/lib
|
||||||
sites/lab/pages
|
sites/lab/pages/*
|
||||||
sites/lab/public/android-chrome-192x192.png
|
sites/lab/public/android-chrome-192x192.png
|
||||||
sites/lab/public/android-chrome-384x384.png
|
sites/lab/public/android-chrome-384x384.png
|
||||||
sites/lab/public/apple-touch-icon.png
|
sites/lab/public/apple-touch-icon.png
|
||||||
|
@ -50,7 +50,9 @@ sites/lab/public/mstile-150x150.png
|
||||||
sites/lab/public/safari-pinned-tab.svg
|
sites/lab/public/safari-pinned-tab.svg
|
||||||
sites/lab/public/site.webmanifest
|
sites/lab/public/site.webmanifest
|
||||||
# but not the indexes
|
# but not the indexes
|
||||||
!sites/lab/pages/*/index.js
|
!sites/lab/pages/index.mjs
|
||||||
|
!sites/lab/pages/code/index.mjs
|
||||||
|
!sites/lab/pages/docs/index.mjs
|
||||||
|
|
||||||
# dev auto-generated content
|
# dev auto-generated content
|
||||||
sites/dev/public/android-chrome-192x192.png
|
sites/dev/public/android-chrome-192x192.png
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
// Components
|
// Components
|
||||||
import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs'
|
import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs'
|
||||||
import { Popout } from 'shared/components/popout.mjs'
|
import { Popout } from 'shared/components/popout/index.mjs'
|
||||||
import { ChoiceLink } from 'shared/components/choice-link.mjs'
|
import { ChoiceLink } from 'shared/components/choice-link.mjs'
|
||||||
import { DocsIcon } from 'shared/components/icons.mjs'
|
import { DocsIcon } from 'shared/components/icons.mjs'
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { useTranslation } from 'next-i18next'
|
||||||
// Components
|
// Components
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs'
|
import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs'
|
||||||
import { Popout, ns as popoutNs } from 'shared/components/popout.mjs'
|
import { Popout, ns as popoutNs } from 'shared/components/popout/index.mjs'
|
||||||
import { WebLink } from 'shared/components/web-link.mjs'
|
import { WebLink } from 'shared/components/web-link.mjs'
|
||||||
|
|
||||||
const ns = ['lab', ...pageNs, ...popoutNs]
|
const ns = ['lab', ...pageNs, ...popoutNs]
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { prebuildRunner } from '../shared/prebuild/runner.mjs'
|
import { prebuildRunner } from '../shared/prebuild/runner.mjs'
|
||||||
|
import { prebuildLab } from '../shared/prebuild/lab.mjs'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This handles the prebuild step for FreeSewing.dev
|
* This handles the prebuild step for FreeSewing.dev
|
||||||
|
@ -25,3 +26,5 @@ prebuildRunner({
|
||||||
posts: false,
|
posts: false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
prebuildLab()
|
||||||
|
|
|
@ -71,6 +71,7 @@ const loadFolderFrontmatter = async (key, site, folder, transform = false, lang
|
||||||
.split(`markdown/${site}/${site === 'dev' ? '' : folder + '/'}`)
|
.split(`markdown/${site}/${site === 'dev' ? '' : folder + '/'}`)
|
||||||
.pop()
|
.pop()
|
||||||
.split(`.md:${key}:`)
|
.split(`.md:${key}:`)
|
||||||
|
|
||||||
if (chunks.length === 2 && chunks[0].length > 1) {
|
if (chunks.length === 2 && chunks[0].length > 1) {
|
||||||
/*
|
/*
|
||||||
* Figure out the language and make sure we have an key for that language
|
* Figure out the language and make sure we have an key for that language
|
||||||
|
@ -81,7 +82,7 @@ const loadFolderFrontmatter = async (key, site, folder, transform = false, lang
|
||||||
/*
|
/*
|
||||||
* Add page to our object with slug as key and title as value
|
* Add page to our object with slug as key and title as value
|
||||||
*/
|
*/
|
||||||
let slug = (prefix + chunks[0].slice(0, -3)).replace(`/./`, `/`)
|
let slug = prefix + chunks[0].slice(0, -3).replace('./', '')
|
||||||
if (slug === prefix) slug = slug.slice(0, -1)
|
if (slug === prefix) slug = slug.slice(0, -1)
|
||||||
if (slug !== 'docs/.')
|
if (slug !== 'docs/.')
|
||||||
pages[lang][slug] = transform
|
pages[lang][slug] = transform
|
||||||
|
@ -127,7 +128,7 @@ const formatDate = (date, slug, lang) => {
|
||||||
* Loads all docs files, titles and order
|
* Loads all docs files, titles and order
|
||||||
*/
|
*/
|
||||||
const loadDocs = async (site) => {
|
const loadDocs = async (site) => {
|
||||||
const folder = site === 'org' ? 'docs' : '.'
|
const folder = site === 'org' ? 'docs' : ''
|
||||||
const titles = await loadFolderFrontmatter('title', site, folder)
|
const titles = await loadFolderFrontmatter('title', site, folder)
|
||||||
// Order is the same for all languages, so only grab EN files
|
// Order is the same for all languages, so only grab EN files
|
||||||
const order = await loadFolderFrontmatter('order', site, folder, false, 'en')
|
const order = await loadFolderFrontmatter('order', site, folder, false, 'en')
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import allLanguages from '../../../config/languages.json' assert { type: 'json' }
|
import i18nConfig from '../config/i18n.config.mjs'
|
||||||
import { loadTranslations } from './shared.mjs'
|
import { loadTranslations } from './shared.mjs'
|
||||||
import { freeSewingConfig as conf } from '../config/freesewing.config.mjs'
|
import { freeSewingConfig as conf } from '../config/freesewing.config.mjs'
|
||||||
import { designs, tags } from '../config/designs.mjs'
|
import { designs, tags } from '../config/designs.mjs'
|
||||||
|
@ -17,17 +17,17 @@ import i18next from 'i18next'
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const extendSiteNav = async (pages, lang) => {
|
export const extendSiteNav = async (pages, lang) => {
|
||||||
const translations = await loadTranslations({
|
const resources = await loadTranslations({
|
||||||
site: 'lab',
|
site: 'lab',
|
||||||
namespaces: ['account', 'design', 'sections', 'tags'],
|
namespaces: ['account', 'sections', 'tags', 'designs'],
|
||||||
languages: allLanguages,
|
languages: [lang],
|
||||||
})
|
})
|
||||||
|
|
||||||
const resources = {}
|
const config = i18nConfig([lang])
|
||||||
resources[lang] = translations[lang]
|
await i18next.init({
|
||||||
i18next.init({
|
|
||||||
lng: lang,
|
lng: lang,
|
||||||
resources,
|
resources,
|
||||||
|
interpolation: config.interpolation,
|
||||||
})
|
})
|
||||||
const { t } = i18next
|
const { t } = i18next
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { freeSewingConfig as conf } from '../config/freesewing.config.mjs'
|
import { freeSewingConfig as conf } from '../config/freesewing.config.mjs'
|
||||||
import { designs } from '../config/designs.mjs'
|
import { designs } from '../config/designs.mjs'
|
||||||
|
import i18nConfig from '../config/i18n.config.mjs'
|
||||||
import { loadTranslations } from './shared.mjs'
|
import { loadTranslations } from './shared.mjs'
|
||||||
import i18next from 'i18next'
|
import i18next from 'i18next'
|
||||||
|
|
||||||
|
@ -17,17 +18,17 @@ import i18next from 'i18next'
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const extendSiteNav = async (siteNav, lang) => {
|
export const extendSiteNav = async (siteNav, lang) => {
|
||||||
const translations = await loadTranslations({
|
const resources = await loadTranslations({
|
||||||
site: 'org',
|
site: 'org',
|
||||||
namespaces: ['account', 'design', 'sections'],
|
namespaces: ['account', 'sections', 'tags', 'designs'],
|
||||||
language: lang,
|
languages: [lang],
|
||||||
})
|
})
|
||||||
|
|
||||||
const resources = {}
|
const config = i18nConfig([lang])
|
||||||
resources[lang] = translations
|
await i18next.init({
|
||||||
i18next.init({
|
|
||||||
lng: lang,
|
lng: lang,
|
||||||
resources,
|
resources,
|
||||||
|
interpolation: config.interpolation,
|
||||||
})
|
})
|
||||||
const { t } = i18next
|
const { t } = i18next
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue