Hi @oscarotero,
I've found Lume CMS incredibly useful for my use case—it’s simple yet rich enough to be powerful. Thank you for sharing it :)
One feature I felt was missing is the ability to use relative paths for asset linking. I prefer relative paths because they make documents more portable and easier to render in different contexts (like GitHub previews), which is how I typically manage my Astro projects.
I've added an option to enable this behavior and would love to contribute it back. I'm open to discussing this further if you think it would benefit the broader audience. Obviously this would a completely optional new feature that you would need to opt-in for.
What’s new?
- A new boolean option,
preferRelativePaths, added toCmsOptions—and passed along toUploadOptionfor convenience. - When enabled:
- File links in the upload modal (opened for editing/creating a document) are shown as paths relative to the current document.
- When inspecting or editing a file field (type
file), relative paths are correctly resolved. - New uploads store their field value as a relative path.
How it works
- When opening upload modals, a
parentURL parameter is now included, containing the current document’s directory. This parameter is kept during navigation inside the modal, via the referrer ([0] for more detail). - On upload, field values are set as relative or absolute according to the chosen option.
- The document template injects
documentPathDir(the document’s directory) alongside thefieldsdefinition throughout the component hierarchy. This allows the correct handling of paths in the UI and logic, and attaching theparentparameter on modals. - When rendering the upload list/edit template, the file data includes a new
relativePathproperty. This property is filled only whenpreferRelativePathis enabled and the document reference is available. The logic here is "best effort."
[0] Note on Implementation:
I considered several options for preserving the parent parameter during modal navigation (such as the Navigation API), but encountered issues intercepting POST-method uploads and wanted to avoid intrusive changes to the server-side URL logic. I opted for a simpler approach that inherits the parameter from the referrer, though I recognize this is a slightly more "fragile" solution.
Let me know if you have any questions, suggestions, or a preferred approach for achieving this. Thanks again for your time and effort! ❤️
- Update the PR descritpion (when code is ready)