Add option to control automatic doctype prepend#6084
Add option to control automatic doctype prepend#6084Sertion wants to merge 4 commits intowithastro:mainfrom Sertion:prepend-doctype-option
Conversation
🦋 Changeset detectedLatest commit: cd2350b The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
yanthomasdev
left a comment
There was a problem hiding this comment.
Thanks for this @Sertion! I added a small docs suggestion for you 🙌
|
trying to understand the use-case better. You want to omit the doctype so you can use Astro pages as partials; does this mean that you also omit the head and body tags? I guess that works since we don't automatically append those. |
That is right. I want to be able to generate HTML output that only contains what I made it to contain without any unexpected side effects. More reasons for other can be found in this discussion. The use case is rendering content for technology such as the nginx SSI module. |
|
We would like to expose this feature, but I think it's unfortunately going to take more than this. Currently our compiler doesn't preserve doctype statements because we expect the rendering logic to add it for us, so enabling this setting would currently break even if a doctype is added manually in your markup. |
|
Thanks for the update @natemoo-re. I looked at @astrojs/compiler to see if I could make the change but I could not. What would be the next step? |
|
I think I'm going to have to come out against this feature. Astro doesn't at present support partial generation. Any hacks we add are going to make everything more brittle and confusing for users. It's called the |
matthewp
left a comment
There was a problem hiding this comment.
This is more complicated than a simple change and should go through the roadmap process. https://github.com/withastro/roadmap/discussions
Should it continue in the existing proposal or would creating a new proposal be preferred? |
|
Thanks for being flexible @Sertion! I think we can continue the discussion in withastro/roadmap#266 and hopefully come up with a more fleshed out proposal from there. |
|
This would have been helpful to generate humans.txt file dynamically (inserting the updated date into). |
Changes
Adds a setting to control the automatic doctype prepender as discussed here.
Testing
Added a new test to the doctype tests that verifies that no doctype is added.
Docs
The current proposed implementation adds a new option (
prependDoctypetypeboolean) to the build (?) configuration./cc @withastro/maintainers-docs for feedback!