Skip to content

Issue: metadata.fmRelFilePath is not a relative path on windows #920

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

Open
lamyseba opened this issue Feb 13, 2025 · 2 comments
Open

Issue: metadata.fmRelFilePath is not a relative path on windows #920

lamyseba opened this issue Feb 13, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@lamyseba
Copy link

Describe the bug
metadata.fmRelFilePath is not a relative path on windows

To Reproduce
I followed the guide here: https://frontmatter.codes/docs/ui-extensibility#registering-a-card-image
It has this bit of code:

registerCardImage(async (filePath, metadata) => {
  return `<span>Your HTML for the card image</span>`;
});

The metadata object is not well documented, but investigating, I could find the metadata.fmRelFilePath property inside it, wich value is the relative path of the document, and wich I used to define the path of the image
On linux, all worked ok.
But on windows, this property contains an absolute path, including drive letter. I don't know if it matters, but for my work on windows, project was on d:\ drive, not c:\

Workaround
As a workaround, I used the metadata.fmRelFileWsPath property, wich contains a relative path, once stripped the [[workspace]] part at the beginning of its value. This works on linux and windows.

Expected behavior
metadata.fmRelFilePath should be a relative path, may it be on windows or on linux.

Device:

  • OS: windows
  • Front Matter CMS Version [10.7.0]
@lamyseba lamyseba added the bug Something isn't working label Feb 13, 2025
@estruyf
Copy link
Owner

estruyf commented Feb 14, 2025

Thanks! I implemented a fix earlier this week for the parsing of Windows paths. It seems that in the latest version of VSCode, there has been a change in how Windows paths are returned. In some cases, it provides a drive letter as uppercase and lowercase in other cases. I believe this is what is causing the issue here as well.

Could you give the latest beta version a try to see if that version already fixes the issue?

https://marketplace.visualstudio.com/items?itemName=eliostruyf.vscode-front-matter-beta

@estruyf estruyf closed this as completed Feb 28, 2025
@lamyseba
Copy link
Author

Hi ! Thank your for your answer, and sorry for the delay of my answer, I do not access widows machines verty often. It turns out that the bug it still here on latest version 10.8.0
FmRelFilePath still contains the full path with drive letter (d:/ on my case), not the relative path. I think this issue should be reopened

@estruyf estruyf reopened this Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants