Skip to content
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

Allow enhancing standard header elements #48

Merged
merged 3 commits into from
May 13, 2024

Conversation

pd95
Copy link
Contributor

@pd95 pd95 commented May 9, 2024

As described in #47 a common problem is that the standard header created by Ignite has to be enhanced with some additional elements.

With this PR I propose the enhancement of the current initializer init(page:,in:) to take an additional parameter which allows appending more elements to Head:

init(for page: Page, in context: PublishingContext, @HeadElementBuilder additionalItems: () -> [HeadElement] = {[]})

This allows enhancing the standard header with as shown below:

Head(for: page, in: context) {
    // Additional headers
    MetaLink(href: "/css/custom.css", rel: "stylesheet")
    Script(file: "/js/custom.js")
}

@pd95
Copy link
Contributor Author

pd95 commented May 9, 2024

Additional to above description, I've moved the creation of the "standard set of headers" to Head.standardHeaders(for:, in:) for easier re-use. Additionally it will be easier to write tests if we don't have to duplicate the elements.

@pd95 pd95 marked this pull request as ready for review May 9, 2024 11:26
@pd95 pd95 changed the title Allow enhancing standard header Allow enhancing standard header elements May 9, 2024
@twostraws
Copy link
Owner

Very nice – thank you!

@twostraws twostraws merged commit c6c1bb1 into twostraws:main May 13, 2024
@pd95 pd95 deleted the feature/Allow-Enhancing-Standard-Head branch May 18, 2024 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants