-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat: field based media/public folders #3208
Conversation
The approach in the OP looks right on. Two questions:
Sent with GitHawk |
@@ -90,6 +93,19 @@ const sortByScore = (a: fuzzy.FilterResult<EntryValue>, b: fuzzy.FilterResult<En | |||
return 0; | |||
}; | |||
|
|||
export const getFieldsNames = (fields: EntryField[], prefix = '') => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see this function used anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right I need to remove it
@@ -106,6 +106,41 @@ const selectors = { | |||
}, | |||
}; | |||
|
|||
const getFieldsMediaLibraryConfigs = (fields: EntryField[]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using reduce
would be cleaner here.
|
f79d416
to
517cb06
Compare
2e2644b
to
d51357d
Compare
When I use a file widget with separate media folder, the correct directory pops up when i'm choosing the file, but after i choose the selected file the directory is not added to the path in the md file. Just the file name. I think I might be doing something wrong, but I'm not sure. I have tried adding it like this:
and also to the widget itself:
and neither of those seems to work. |
Thanks for reporting @jeremiahfallin, that looks like a bug with setting the default |
That worked for me. I opened issue #3483 and included the workaround. Thanks! |
Hey guys, I am not sure if this is the right place to leave a comment, but I have noticed an issue regarding these changes. It seems that e.g. path of the image
When I am using image widget without media_folder and public_folder
Everything is working fine with published content, but during the creation I am not able to get correct path to display added image in preview because returned path |
Can you try calling If that doesn't work please open a new issue. Field based media/public folders are quite new and not documented properly yet |
Maybe I'm doing something wrong but I have a real struggle with this one. I want my post to have one cover that is stored in assets so Hugo is able to resize it. Also my post have multiple images inside text (markdown widget) that I want to be stored in static so I can add these with the UI. Hope it's clear: cover in assets to resize, images inside text in static to add them without any code. I came up with this config.yml: backend:
name: git-gateway
branch: master
media_folder: 'static/img/blog'
public_folder: '/img/blog'
collections:
- name: 'blog'
label: 'Posts'
folder: 'content/blog'
create: true
slug: '{{year}}{{month}}{{day}}{{hour}}{{minute}}{{second}}'
editor:
preview: true
fields:
- label: 'Title'
name: 'title'
widget: 'string'
- label: 'Cover'
name: 'image'
widget: 'image'
media_folder: '/assets/covers'
public_folder: '/covers'
allow_multiple: false
- label: 'Post'
name: 'body'
widget: 'markdown' Paths to files appears as I expect them to, like that: ---
title: Test
date: 2020-11-01T19:40:17.107Z
author: gman
image: /covers/lighthouse.jpg
---
Post body
![Sample](/img/blog/desert.jpg) But the cover is stored in So it looks like I can't set field based media folder... Is it even possible to do it as I described? Or I didn't understand docs right? Or I did something wrong? Here is the repo if needed |
Hi @gtitov can you please open a new issue with the information you shared here? |
Done! |
Fixes #3201
Still requires some manual & automated tests, but will let you have a config like this:
Example PR: https://github.com/erezrokah/netlify-cms-reproductions/pull/74/files
Update
Another Update
Fixes #3199