Closed einarpersson closed 1 year ago
I don't know it this is stupid but my current workaround became
const slugs = slug.split('/')
if (slugs.length === 1) {
post = (await import(`../posts/${slugs[0]}/post.md`)) as Post
} else if (slugs.length === 2) {
post = (await import(`../posts/${slugs[0]}/${slugs[1]}/post.md`)) as Post
} else if (slugs.length === 3) {
post = (await import(`../posts/${slugs[0]}/${slugs[1]}/${slugs[2]}/post.md`)) as Post
} else {
throw Error(`Exceded maxiumum nesting level: ${slug} `);
}
Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ
2.79.1
Expected Behavior / Situation
I have a blog for personal writing using SvelteKit and mdsvex. All posts are in markdown format and are located neatly within one folder.
eg.
src/posts/blog/2022-12-02-soon-it-is-christmas/page.md
I'd like to achieve a situation where I more generally can add subfolders with markdown files, and have this being translated into pages.
eg.
src/posts/random/i-had-a-dream-last-night/page.md
src/posts/random/politics/how-can-we-change-the-world/page.md
src/posts/favorite-quotes/page.md
src/posts/lab/visualizations/strange-attractors-are-cool/page.md
In this case the slug (note sure it is the right term?) could be
random/i-had-a-dream-last-night
orlab/visualizations/strange-attractors-are-cool
.I thought this would "just work" but stumbled upon the limitations specified here
Actual Behavior / Situation
It does not seem to work due to the limitations linked above. In particular
It seems to me that it forces me to add sveltekit endpoints for every possible folder and subfolder which is killing the whole idea of creating a space for "fluent writing and content creation".
Modification Proposal
The limitations are motivated by "to avoid possible foot guns" such as "you could in theory import anything from your entire file system" (which of course is bad).
But to me this feels too restrictive and limits me from doing things that I think are safe. Why wouldn't I be allowed to import anything from a subfolder
./my-public-files/
for example? We also have https://github.com/rollup/plugins/issues/1009Suggestion: Remove "Globs only go one level deep" limitation. Or explain why it is necessary.
I understand that there might be things I do not understand (😅 ) but I hope you understand me :)