sveltia / sveltia-cms

Alternative to Netlify/Decap CMS. Fast, lightweight, Git-based headless CMS. Modern UX, first-class i18n support, open source & free. Made with Svelte.
MIT License
862 stars 43 forks source link

File collection media/public folder #155

Closed BlueFrog130 closed 3 months ago

BlueFrog130 commented 4 months ago

As of now, the media_folder and public_folder properties are not respected for file collections, is this something that is planned on being implemented?

I don't see any documentation on Decap specifically for media/public folders in file collections.

I haven't done much digging, but I assume the process for saving file collection assets would be the same as folder collections.

kyoshino commented 4 months ago

@BlueFrog130 Thanks for the heads-up! Many things are unclear in the Decap docs. I’m aware of at least one issue with file collections:

(I think the i18n config has the same issue/limitation.)

Regardless of the Decap implementation, I’m happy to get rid of the limitation in Sveltia. 🙂

kyoshino commented 4 months ago

@BlueFrog130 Can you paste a snippet of your configuration to make sure I’m on the same page as you?

BlueFrog130 commented 3 months ago

@kyoshino

Here is a snippet that I am using:

collections:
  - label: Settings
    name: settings
    icon: Settings
    # Should the folder config be here
    media_folder: /src/uploads/settings 
    public_folder: /uploads/settings
    files:
      - label: Website Settings
        name: settings
        file: content/settings/settings.json
        # or here?
        media_folder: /src/uploads/settings
        public_folder: /uploads/settings
        editor:
          preview: false
        fields:
          ...
kyoshino commented 3 months ago

Thanks! The media_folder and public_folder options for the collection itself should work at least in Sveltia. These options for each file are not supported at this time.

kyoshino commented 3 months ago
  - label: Settings
    name: settings
    icon: Settings
    media_folder: /src/uploads/settings 
    public_folder: /uploads/settings
    files:
      - label: Website Settings
        name: settings
        file: content/settings/settings.json
        editor:
          preview: false
        fields:
          - name: title
            label: Title
            widget: string
          - name: image
            label: Image
            widget: image

Here’s a screenshot of my local testing:

image
BlueFrog130 commented 3 months ago

Odd, my image uploads are going in the default media folder

media_folder: /src/uploads
public_folder: /uploads
collections:
  - label: Settings
    name: settings
    icon: Settings
    media_folder: /src/uploads/settings
    public_folder: /uploads/settings
    files:
      - label: Website Settings
        name: settings
        file: /content/settings/settings.json
        editor:
          preview: false
        fields:
          - label: Site Title
            name: title
            widget: string
          - label: Site Description
            name: description
            widget: text
          - label: Site Favicon
            name: favicon
            widget: image

image

kyoshino commented 3 months ago

Perhaps due to the backslash weirdness on Windows. Will check.

kyoshino commented 3 months ago

I was able to reproduce the problem locally. For some reason, it fails when a file collection is the first collection. Fix coming.

BlueFrog130 commented 3 months ago

@kyoshino

You the best. This project is awesome and I plan to use it a bunch.

Keep up the great work 👍

kyoshino commented 3 months ago

The fix landed in v0.34.2!