Skip to content

Latest commit

 

History

History
15 lines (12 loc) · 478 Bytes

conditionally-run-a-step.md

File metadata and controls

15 lines (12 loc) · 478 Bytes

How to conditionally run a publishing step

If you have a publishing step that you don’t necessarily want to run every time that your website is generated or deployed, then wrap it in an if conditional to only run it in case an expression evaluated to true:

func shouldAddPrefixToItems() -> Bool {
    ...
}

try MyWebsite().publish(using: [
    .if(shouldAddPrefixToItems(), .mutateAllItems { item in
        item.title = "Prefix: " + item.title
    })
])