Resolve the issue that relative paths are unproperly handled#371
Resolve the issue that relative paths are unproperly handled#371Spr-Aachen wants to merge 2 commits into
Conversation
|
If there's anything I got mistakened, please let me know:) |
|
The PR touches on way too many files More importantly, I think you misunderstand the way media paths work: https://pagescms.org/docs/configuration/media/ We define 2 paths: media:
input: src/media
output: /mediaThe idea is that The I know that a lot of Astro users have media collocated with their media. Most other setups (Next.js, Hugo, 11ty, etc) tend to have all media in a single folder. I've discussed before adding support for collocated media, but for now I would just recommend you use a central folder for all of your media. |
Thank you for your patient answer, I do know the way media:
- name: posts
input: src/content/posts
output: /src/content/posts
content:
- name: posts
path: src/content/posts
fields:
- { name: cover, type: image, options: {media: posts} }The problem is, the media files in my project stored in the same folder as the markdown content, which is a common pattern in Astro. |
|
Sure. Can you describe how Decap CMS actually handle that? The main issue for me is for new content creation: if you don't have an entry yet for your post, how can we know where to upload images? |
|
Feel free to rework a new PR |
Hi, yesterday I've opened a new PR |
How Decap CMS Handles This Solution for Pages CMS My co-mate has pushed a commit solving this issue via modifying |
|
OK, but how do we handle uploading media if the file hasn't been uploaded yet? Also, we need to enforce that the entry has creates a subfolder (e.g. |
I think the new PR has resolved the first concern by adding logic to fill For the second concern (subfolder requirement), I think it might be able to handle in two ways:
I'll try implementing this in the new PR if you give me a direction. |
|
Ok I found a issue with higher priority and I've opened the PR After solving that issue can we start adding features like creating subfolders |
Issue
When having a post (e.g. "xxx/blob/main/src/content/posts/post.md") with relative image path (e.g. "./cover.jpg" referring to "xxx/blob/main/src/content/posts/cover.jpg") set inside frontmatter, the image fails to display in pages-cms.


By clicking

View On GitHubbutton you'll find it pointing to an incorrect url (e.g. "xxx/blob/main/cover.jpg").Solution
Add
entryPathprop to make sure the relative paths can be properly handled