-
Notifications
You must be signed in to change notification settings - Fork 32
Adds support for global key #42
base: master
Are you sure you want to change the base?
Conversation
@cameronroe Hey hey, thanks so much for bringing this in. :) Test are failing currently? I'll have a deeper look into it on monday. :) |
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.
Just had a quick look. :)
@@ -139,6 +143,29 @@ function processEntriesForFile (file, entries, options) { | |||
return files | |||
} | |||
|
|||
function filterEntries (entries, file, options) { |
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.
JSDocs are missing.
@cameronroe Still failing? Do you need help with this? |
@stefanjudis Looks like a directory wasn't pushed to git, then .gitkeep broke the tests. Just fixed. Should be good for a review. 👍 |
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.
Okay I looked over the code and it looks good. The only thing I'm worried about is documentation...
It's becoming really complex and I think we should improve that now or in another PR.
For this PR what would be great would be a reworked getting started guide maybe also including a few screenshots on how to connect contentful with metalsmith?
What do you think? We can do this in a seperate PR, if you like, but I wouldn't release it without solid help, docs and guidance.
### `entry_extension` *(optional)* | ||
|
||
If you specify `entry_key`, you will need to specify the entry extension for all file keys. This will be appended to the key on Contentful entries that contain the `entry_key`. | ||
|
||
### `filterTransforms` *(optional)* |
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 feel like we need a lot more documentation now... And maybe update the getting started guide.
This addition makes total sense and is probably the way to go, but it's not easy to understand in the beginning.
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.
Right, do you think there should be another section similar to this one? I could write up a longer description under this section and then link it to the docs/global-settings.md
?
"space_id": "YOUR_CONTENTFUL_SPACE_ID", | ||
"entry_key": "_key", | ||
"entry_extension": "md", | ||
"contentful": { |
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.
~~Is the contentful property correct here?~~~
Found it.
@@ -82,6 +97,8 @@ layout: posts.html | |||
--- | |||
``` | |||
|
|||
### [`contentful` *(optional)*](source-file-settings.md) |
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 needs definitely more explanation. :)
Sure, that's cool. What were you thinking for the getting started guide? We can do that in this PR. |
@cameronroe I feel like we should rework the getting starting guide, as this implementation feels like the right way to go. So I'd recommend it for every new user (not breaking the old functionality yet). IMO the documentation of So in my head it's kind of like this (including screenshots of contentful.
And just an idea that comes to mind right now... I would be cool when we could provide the base structure into contentful and explain it in the getting started section. :) Great that we can do this in this PR. 👍 Does all this make sense? |
I updated the readme with all the correct configs to get started. I'm not so sure exactly what you're needing in the other sections. Everything looks like it's already detailed. Did you want to update it with something different? |
For me the main goal is to make it really beginner accessible, where I still think it could be better. But you did a great job and let's not open up the scope more. I'll open up a follow up then. I'll check the functionality and do a test run in the next 2 hours and then let's see. :) |
'entry_key': '_key', | ||
'entry_extension': 'md', | ||
'contentful': { | ||
'content_type': '2wKn6yEnZewu2SCCkus4as' |
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 would change this to CONTENT_TYPE_ID
to make it clear to users that this field can be configurable
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.
Yeah, was wondering about that. Is that fetching all the data under that content_type_id
?
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.
@cameronroe yes it is fetching entries under that contentType
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.
Cool. What would be the best way to configure fetching all data from Contentful for users who want to build a site with multiple content_types
? Should that be an array then instead of a string?
Sorry for the delay here, I'll really try to get it done this week. :( |
So I gave it a try. Sorry again for the delay. :( There are a few things I noticed. Global configuration and documentationI ran the PR with the following configuration:
and this leads to an exception
It was not clear to me, that I have to set a
I feel like improved documentation with a step by step guide is needed. I don't mind opening up two documents with "How to's"... Code duplicationWhen reading the code I noticed a few duplications that can be avoided.
and
this could be resolved by restructuring the index file a bit.
Overall I feel like we have a conceptual issue (the I really appreciate your work and would like to keep it going. :) Thanks. |
@stefanjudis Sure. The
|
@stefanjudis Any thought on that idea? |
@cameronroe Yeah, I think this makes way more sense! 👍 |
Hey, just wondering if this pr is still considered for merging? |
This hasn't been looked at in months. Any ideas @stefanjudis ? |
@cameronroe Oh well... sorry about that. 😢 That slipped through. I'll have a look again asap. |
No worries! Let me know how I can help. I may also need to review what was written here.. 🙃 |
#36 With this PR, users can now add
entry_key
andentry_extension
to their global settings and transform entries from Contentful into files within Metalsmith. The files are created from theentry_key
property and must be referenced properly to the path of the file. The file with have theentry_extension
as the extension to the file. The files will add contents as a Buffer for other Metalsmith plugins.Example:
An entry in Contentful with properties:
Output: