Skip to content

Commit

Permalink
DN-6: Correctly build the post paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereckmezquita committed Dec 28, 2024
1 parent aa1fb34 commit 37a80d6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions client/src/utils/mdx/fetchPostsMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ export function extractSinglePostMetadata(filePath: string): PostMetadata {
const { summary, frontmatter } = stripMdx<PostMetadata>(filePath);
const date: string = DATE_YYYY_MM_DD(frontmatter.date);

// strip the abs path so it's the root of the website
// i.e. client/src/app/
const fileRoot: string = filePath
.split('app/')[1]
.replace('/posts/', '/')
.replace('.mdx', '');
// Instead of manually splitting by "app/"
const relativePath = path.relative(ROOT_DIR_APP, filePath);
// e.g. relativePath = "blog/posts/20241220_bioinformatics-cheat-sheet.mdx"

// Then normalise further
let fileRoot = relativePath.replace('/posts/', '/').replace('.mdx', '');

return {
slug: path.basename(filePath, '.mdx'), // removes ext
Expand Down

0 comments on commit 37a80d6

Please sign in to comment.