estruyf / vscode-front-matter

Front Matter is a CMS running straight in Visual Studio Code. Can be used with static site generators like Hugo, Jekyll, Hexo, NextJs, Gatsby, and many more...
https://frontmatter.codes
MIT License
1.86k stars 70 forks source link

Issue: Incorrect path saved in front matter image field by image selector #755

Open tohagan opened 5 months ago

tohagan commented 5 months ago

Describe the bug

Image selector is saving the wrong path for Astro.

To Reproduce

Steps to reproduce the behavior:

  1. Configure frontmatter.json to contain the following:
 ...
  "frontMatter.content.pageFolders": [
    {
      "title": "posts",
      "path": "[[workspace]]/src/content/posts/en",
      "contentTypes": [
        "post"
      ]
    }
  ],
  "frontMatter.content.publicFolder": {
    "path": "src/assets",
    "relative": true
  },
  "frontMatter.taxonomy.contentTypes": [
   ...
      {
        "title": "Image",
        "name": "Image",
        "type": "image",
        "isPreviewImage": true
      },
  ]
...
  1. Edit a Markdown document
  2. Select an image from the src/assets directory

Expected Behavior

The correct image is displayed in the field but the path saved in the image field is ../../../assets/image.jpg instead of the expected src/assets/image.jpg.

Desktop (please complete the following information):

Windows 10

Possible Cause

This might be related in some way to the fact that I have to select the English subfolder "[[workspace]]/src/content/posts/en",

estruyf commented 5 months ago

There is nothing wrong with the path as this is how it needs to be for Astro:

<!-- Local image stored in src/assets/ -->
<!-- Use a relative file path or import alias -->
![A starry night sky.](../assets/stars.png)

<!-- Image stored in public/images/ -->
<!-- Use the file path relative to public/ -->
![A starry night sky.](/images/stars.png)

<!-- Remote image on another server -->
<!-- Use the full URL of the image -->
![Astro](https://example.com/images/remote-image.png)

Source: https://docs.astro.build/en/guides/images/#images-in-markdown-files