fix: paths

This commit is contained in:
tresabhi committed 2025-01-16 20:34:28 -06:00
1 parent bcde319ac1
commit ee94d762d0
3 files changed
+35 -25

No files matched your search

@@ -2,28 +2,37 @@
import type { GetStaticPaths } from 'astro';
import { readFile } from 'fs/promises';
import BaseLayout from '../../../../../layouts/BaseLayout.astro';
import { getStaticPaths as parentGetStaticPaths } from '../../../index.astro';
import { Page } from './_index';
export const getStaticPaths = (async () => {
const ROOT = '../../../../../../../docs/';
const files = import.meta.glob('../../../../../../../docs/**/*.md', {
const parentPaths = parentGetStaticPaths();
const ROOT = '../../../../../../../../docs/';
const files = import.meta.glob('../../../../../../../../docs/**/*.md', {
eager: true,
});
return await Promise.all(
Object.keys(files).map(async (file) => {
const couple = file.replace(ROOT, '').split('/');
couple[1] = couple[1].replace('.md', '');
const content = await readFile(
`../../docs/${couple[0]}/${couple[1]}.md`,
).then((buffer) => buffer.toString());
return (
await Promise.all(
Object.keys(files).map(async (file) => {
const couple = file.replace(ROOT, '').split('/');
couple[1] = couple[1].replace('.md', '');
const content = await readFile(
`../../docs/${couple[0]}/${couple[1]}.md`,
).then((buffer) => buffer.toString());
return {
params: { directory: couple[0], document: couple[1] },
props: { content },
};
}),
);
return parentPaths.map((parent) => ({
params: {
...parent.params,
directory: couple[0],
document: couple[1],
},
props: { content },
}));
}),
)
).flat();
}) satisfies GetStaticPaths;
const { content } = Astro.props;
@@ -8,10 +8,10 @@ import BaseLayout from '../../../../layouts/BaseLayout.astro';
export { getStaticPaths } from '../../index.astro';
// this can't be used in template literal :(
const ROOT = '../../../../../../docs/changelogs/';
const ROOT = '../../../../../../../docs/changelogs/';
const versions = Object.keys(
import.meta.glob(`../../../../../../docs/changelogs/*.md`, {
import.meta.glob('../../../../../../../docs/changelogs/*.md', {
eager: true,
}),
)