Fix missing pages
This commit is contained in:
parent
b6b59e3ae2
commit
c10df3fa2c
@ -35,21 +35,21 @@ export default function (config) {
|
||||
|
||||
// add collection for pages
|
||||
config.addCollection('categories', async (collection) => {
|
||||
const locales = (await fs.readdir('src/content/')).filter((c) => !c.match(MD_REGEX))
|
||||
const languages = (await fs.readdir('src/content/')).filter((c) => !c.match(MD_REGEX))
|
||||
const categories = new Map()
|
||||
|
||||
for (const locale of locales) {
|
||||
const categoryNames = (await fs.readdir(`src/content/${locale}`)).filter((c) => !c.match(MD_REGEX))
|
||||
for (const lang of languages) {
|
||||
const categoryNames = (await fs.readdir(`src/content/${lang}`)).filter((c) => !c.match(MD_REGEX))
|
||||
|
||||
categories.set(locale, new Map())
|
||||
categories.set(lang, new Map())
|
||||
|
||||
for (const catName of categoryNames) {
|
||||
categories.set(locale, collection.getFilteredByGlob(`src/content/${locale}/${catName}/index.md`).reduce((accumulator, category) => {
|
||||
categories.set(lang, collection.getFilteredByGlob(`src/content/${lang}/${catName}/index.md`).reduce((accumulator, category) => {
|
||||
accumulator.set(category, [])
|
||||
return accumulator
|
||||
}, categories.get(locale)))
|
||||
}, categories.get(lang)))
|
||||
|
||||
categories.set(locale, collection.getFilteredByGlob(`src/content/${locale}/${catName}/*.md`).reduce((accumulator, category) => {
|
||||
categories.set(lang, collection.getFilteredByGlob(`src/content/${lang}/${catName}/*.md`).reduce((accumulator, category) => {
|
||||
const categoryIsKey = accumulator.keys().find(key => category === key)
|
||||
if (!categoryIsKey) {
|
||||
const categoryKey = accumulator.keys().find(key => category.data.tags.includes(key.data.tags[0]))
|
||||
@ -58,15 +58,22 @@ export default function (config) {
|
||||
}
|
||||
|
||||
return accumulator
|
||||
}, categories.get(locale)))
|
||||
}, categories.get(lang)))
|
||||
}
|
||||
}
|
||||
|
||||
return { en: map2arr(categories.get('en')), fr: map2arr(categories.get('fr')) }
|
||||
})
|
||||
|
||||
config.addCollection('pages', (collection) => {
|
||||
return collection.getFilteredByGlob('src/content/*.md').filter(p => p.page.fileSlug)
|
||||
config.addCollection('pages', async (collection) => {
|
||||
const languages = (await fs.readdir('src/content/')).filter((c) => !c.match(MD_REGEX))
|
||||
const pages = {}
|
||||
|
||||
for (const lang of languages) {
|
||||
pages[lang] = collection.getFilteredByGlob(`src/content/${lang}/*.md`).filter(p => !p.page.fileSlug.match(lang))
|
||||
}
|
||||
|
||||
return pages
|
||||
})
|
||||
|
||||
return {
|
||||
|
@ -30,7 +30,7 @@
|
||||
<li webc:for="category of collections.categories[lang]" >
|
||||
<a :href="category[0].url" @text="category[0].data.title"></a>
|
||||
</li>
|
||||
<li webc:for="page of collections.pages" >
|
||||
<li webc:for="page of collections.pages[lang]" >
|
||||
<a :href="page.url" @text="page.data.title"></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
Loading…
x
Reference in New Issue
Block a user