-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat(core): Add {{dirname}} to summary and preview_path #4279
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(core): Add {{dirname}} to summary and preview_path #4279
Conversation
| const pathTemplate = collection.get('preview_path') as string; | ||
| let fields = entry.get('data') as Map<string, string>; | ||
| fields = addFileTemplateFields(entry.get('path'), fields); | ||
| fields = addNestedPath(entry.get('meta')?.get('path'), fields); |
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.
Typescript yelled at me if I used entry.getIn(['meta', 'path'])
| identifier = '', | ||
| data = Map<string, unknown>(), | ||
| processor?: (value: string) => string, | ||
| processor?: (value: string, key: string) => string, |
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.
Ideally it should be processor?: (key: string, value: string) => string, But I figured it was a less of a sweeping change to append the parameter instead.
erezrokah
left a comment
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.
Thanks @keegan-lillo. The code changes look good, however we would like not to separate the terms path and nested_path - that is an internal CMS implementation.
The term meta is used to handle entry data that is not present in any field that is serialised to the output file.
Could we apply this for path in general and maybe use _path as a key to make is less of a breaking change if someone uses path as a field?
|
@erezrokah thanks for the review! How about maybe Also, where would be the best place to document the change? |
We have a suggestion outlined here #3100, but it is a breaking change. Since we have For documentation, |
|
Ah Yup. That makes sense. Okay so to clarify: let's just go with |
Let's go with |
Isn't that the opposite of the current behaviour? From: https://www.netlifycms.org/docs/configuration-options/#slug
Apologies for all the questions. Just want to be 100% clear. |
You're right, I didn't give enough thought. Doing so will prevent someone from using both the built in template and the field in the same template. How about |
|
Cool. That makes sense to me. Thanks for the feedback! |
5071f87 to
1c6f31f
Compare
|
@erezrokah This is now ready for review. I know we discussed using |
| label: loadedEntry.file.label, | ||
| author: loadedEntry.file.author, | ||
| updatedOn: loadedEntry.file.updatedOn, | ||
| meta: { path: prepareMetaPath(loadedEntry.file.path, collection) }, |
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 noticed this was missing in the previous implementation.
Yes, this is much better! |
erezrokah
left a comment
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.
This is great @keegan-lillo.
Appreciate the discussion, tests and docs. Amazing work!
Related to: #445
Summary
This PR allows the generated
meta.pathto be accessible insummaryandpreview_pathwhen using nested collections.eg:
Docs Preview
https://deploy-preview-4279--netlify-cms-www.netlify.app/docs/configuration-options/#preview_path
https://deploy-preview-4279--netlify-cms-www.netlify.app/docs/configuration-options/#summary
https://deploy-preview-4279--netlify-cms-www.netlify.app/docs/beta-features/#folder-collections-media-and-public-folder
Questions for reviewers
Thoughts on usingGoing withnested_pathas the template key?dirnameWhere should I document this? In the Beta Features orsummaryandpreview_pathsections?Test plan
Pathset todir-a/dir-b/hello-worldand aTitleofHello Worldnested_path):Hello Worlditem to go into edit viewhttps://example.com/dir-a/dir-b/hello-worldTo Do
A picture of a cute animal (not mandatory but encouraged)
My parents' dogs:
