Skip to content

Instantly share code, notes, and snippets.

@Tc-001
Created December 22, 2022 18:31
Show Gist options
  • Select an option

  • Save Tc-001/8dd89f422212371a99a658960f9ae0bb to your computer and use it in GitHub Desktop.

Select an option

Save Tc-001/8dd89f422212371a99a658960f9ae0bb to your computer and use it in GitHub Desktop.
Add doctype in honojs's JSX layout
function DoctypeComponent() {
let s = new String("<!DOCTYPE html>") as any
s.isEscaped = true
return s
}
export const Layout = (props: { children?: string }) => (
<Fragment>
<DoctypeComponent />
<html lang="en">
...
</html>
</Fragment>
)
@Tc-001
Copy link
Author

Tc-001 commented Dec 22, 2022

Thank me later lol, this took some reading to figure out
Fun fact, you can't do dangerouslySetInnerHTML on Fragment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment