-
Notifications
You must be signed in to change notification settings - Fork 153
fix file path resolution #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
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.
requesting a few changes 🙏
a084f73
to
931d740
Compare
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.
Okay! In the latest changes…
- Improved type safety
- Upgraded acorn to use stricter types
- Imports are no longer treated as file attachments, but handled specially 😌
- Fixing the relative path computation in a number of places
- Found and fixed a new bug Imports within inline expressions aren’t preloaded #123
I really want to add more tests here, but I’m waiting for @wiltsecarpenter’s #102.
I am seeing
Screen.Recording.2023-11-08.at.8.30.19.PM.mov |
src/navigation.ts
Outdated
@@ -20,7 +20,7 @@ export async function readPages(root: string): Promise<NonNullable<RenderOptions | |||
continue; | |||
} | |||
const name = basename(file, ".md"); | |||
const page = {path: `/${join(dirname(file), name)}`, name: parsed.title ?? "Untitled"}; | |||
const page = {path: join(dirname(file), name), name: parsed.title ?? "Untitled"}; |
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.
since navigation is for the serving path and join
is for the source path, I think we'd want to keep the original logic? Is join typically used only for server-side?
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.
Is this regarding the leading slash? I’ll change the code to favor source paths starting with a leading slash per the other comment.
Regarding join, we’re currently using it both for file system paths and for URLs. That’s a little messy since the operating system isn’t guaranteed to use a forward slash for a path delimiter, but it’ll be quite a bit of work to disentangle these two concepts if we want to… and I think even windows uses a forward slash now?
Thanks for catching these bugs Cindy! I feel more confident that it is correct now. I want to followup with more tests after this (for example, for local fetch and promoting linked stylesheets to file attachments). |
Fixes #117. Fixes #123. Related #87 (comment).