-
Notifications
You must be signed in to change notification settings - Fork 4
Initial working version with MDX remote #9
base: main
Are you sure you want to change the base?
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/yenly/foamy-nextjs/CBK1RbJXQQH6ukd4N7bq3ZJu5KYM |
Also updated foam settings from the upstream template #8 |
Would you explain more regarding 'wikilinks not rendering properly?' I find a screen capture would be helpful. I have MDX remote configured for my personal notes site (private repo) and have encountered a similar issue with nested directories. The technical decision I went with is a longer discussion and potentially too opinionated for this starter. Happy to discuss if you'd like. I have special handling of the wikilinks in AnchorTag component in this file in case you may find it helpful to know. I see 1 failing check on vercel deployment and the error is:
If you're still working on this PR, then let me know when you're ready or need help. I don't have time to pull it down and play with it today. I may have time in the next few days. I appreciate the work you're putting into this! |
For some reason nested wikilinks lose their parent directory: // index.mdx
### Examples
- [[note]] in subfolder using remark footnotes
[//begin]: # "Autogenerated link references for markdown compatibility"
[note]: notes/note "Note"
[//end]: # "Autogenerated link references" This link is being rendered as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zomars I'm excited to see you got nested directories to work with next-MDX-remote! One thing to clarify in issue #4 is I want to add support to pull MDX files from a directory source outside of pages directory. I don't want to remove MDX support in pages directory. The reason being is it will give developers more flexibility. _posts directory can be where all the second brain notes and pages directory can contain about-me.mdx, newsletter-signups.mdx, dashboard.mdx, project.mdx, conference-talks.mdx, etc. My aim for this starter is to be flexible to what others can easily build with their own opinions. I had set the pages to be compatible with pageExtensions: ['js', 'jsx', 'mdx', 'md'],
because I remember there was some chatter in Foam Discord around it.
pages/[...slug].js
Outdated
[ | ||
remarkWikiLink, | ||
{ | ||
hrefTemplate: (permalink) => `${permalink}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like here is where remarkWikiLink is not returning the full path. Line 56 outputs /note
instead of /note/note.
A possible fix is to construct the correct href from postFilePath.
pages/[...slug].js
Outdated
remarkWikiLink, | ||
{ | ||
hrefTemplate: (permalink) => `${permalink}`, | ||
pageResolver: (name) => [name.replace(/ /g, '-').toLowerCase()], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart idea to use remark-wiki-link to remove the [] but kebab case links aren't the desired look. My AnchorTag component converts it to use the title of the note. Here you are converting the link back to the kebab case. Capitalize case like how Foam documentation displays is best.
Thanks for the feedback @yenly. One question thought, wouldn't having both methods for generating pages from markdown be confusing? I'll check on the other feedback and get back to you ASAP. |
Not at all and it depends on the developer. A really good example to look at is Lee Robinson's personal website. He open-sourced his codebase. https://github.com/leerob/leerob.io. |
} | ||
} | ||
|
||
export async function getAllFilesFrontMatter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this imported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nowhere yet... I've kept it in case of wanting a blog listing somewhere
This is great. Really close to what I'm aiming for. I really appreciate the I'm finding it tricky to get the nested dynamic routes to operate properly, as Foam generates relative link references without a leading I've enjoyed using Also, have you considered using Now I'm looking at passing the frontmatter along to the template for a meta layer of navigation. And maybe some listings as you mention. |
I took inspiration from Lee's website and hacked my way trough it.
I would need to see a proper example to be able to debug this.
This seems a nice to have feature, although they mention that they use undocumented Next APIs and they're prone to change unexpectedly.
I don't see why not. :) |
I've replaced the MDX loader with MDX remote
refs #4
I've got it working with nested directories, but I'm having trouble with wikilinks not rendering properly.