Initial import
This commit is contained in:
35
src/app/manifests/docs.manifest.ts
Executable file
35
src/app/manifests/docs.manifest.ts
Executable file
@@ -0,0 +1,35 @@
|
||||
import type { MarkdownDocumentEntry } from '../../components/markdownPreview';
|
||||
|
||||
const docsMarkdownModules = import.meta.glob('/docs/**/*.md', {
|
||||
query: '?raw',
|
||||
import: 'default',
|
||||
}) as Record<string, () => Promise<string>>;
|
||||
|
||||
const featureMarkdownModules = import.meta.glob('../../features/**/*.md', {
|
||||
query: '?raw',
|
||||
import: 'default',
|
||||
}) as Record<string, () => Promise<string>>;
|
||||
|
||||
function createMarkdownEntries(
|
||||
modules: Record<string, () => Promise<string>>,
|
||||
): MarkdownDocumentEntry[] {
|
||||
const sortedPaths = Object.keys(modules).sort((left, right) => {
|
||||
const isLeftWorklog = left.includes('/docs/worklogs/');
|
||||
const isRightWorklog = right.includes('/docs/worklogs/');
|
||||
|
||||
if (isLeftWorklog && isRightWorklog) {
|
||||
return right.localeCompare(left);
|
||||
}
|
||||
|
||||
return left.localeCompare(right);
|
||||
});
|
||||
|
||||
return sortedPaths.map((path, index) => ({
|
||||
path,
|
||||
load: modules[path],
|
||||
order: index,
|
||||
}));
|
||||
}
|
||||
|
||||
export const docsMarkdownEntries = createMarkdownEntries(docsMarkdownModules);
|
||||
export const featureMarkdownEntries = createMarkdownEntries(featureMarkdownModules);
|
||||
Reference in New Issue
Block a user