Skip to content

Commit 2d99f1b

Browse files
authored
Use path.sep instead of “/“ (#1321)
1 parent 293dcb8 commit 2d99f1b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/components/PostList.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { MdxFile } from '@/util/loadMdx.server';
22
import Link from 'next/link';
3+
import path from 'path';
34

45
/*
56
PostListItem is each resource under a section of content on the homepage.
@@ -67,16 +68,20 @@ export function formatFileListItemsForPostList(
6768
return null;
6869
}
6970

70-
return items.map(
71-
(item): PostListItem => ({
71+
return items.map((item): PostListItem => {
72+
const parts = item.slug.split(path.sep).filter((part) => {
73+
return !!part && part !== 'content';
74+
});
75+
76+
return {
7277
title: item.meta.title,
7378
description: item.meta.description,
74-
href: `/${item.slug.replace('content/', '')}`,
79+
href: `/${parts.join('/')}`,
7580
children: formatFileListItemsForPostList(
7681
item.children,
7782
depth,
7883
internalCurLevel + 1,
7984
),
80-
}),
81-
);
85+
};
86+
});
8287
}

0 commit comments

Comments
 (0)