Publish
Publish copied to clipboard
Don’t force section on addItem
This allows the configure closure to set an entire new item, including changing it’s section.
I guess the big question is, is there a reason to force the section?
The scenario for this is the following: In my website I have a section for all the articles of the blog and I want to have another section that displays only specific articles based on some criteria. This doesn't seem straightforward so what I'm doing is the following:
- Add a section case in the enum.
- Make an empty folder so Publish doesn't error. (the folder doesn't need any md, we will add them with a step)
- Make a step that adds the items to the section:
let items = context.items...
for item in items {
context.sections[.section].addItem(
at: item.path,
withMetadata: item.metadata
) { newItem in
newItem = item
}
}
Without this patch the path of the new items will be pointing to the new section we're creating, but what I really want is that their path points to their original location.
Is there a better approach to build something like this?