š·ļø Declarative attribute binding for the root html element
npm i @jill64/svelte-html
By passing a key-value set to the <SvelteHTML />
component, attributes are bind to the root html element.
<script>
import { SvelteHTML } from '@jill64/svelte-html'
</script>
<SvelteHTML lang="en" prefix="example" />
ā
<html lang="en" prefix="example">
<!-- ... -->
</html>
Attribute binding with <SvelteHTML>
is only applied on the client.
To assign arbitrary attributes during SSR, use the apply
function in the handle
hook.
// hooks.server.js
import { apply } from '@jill64/svelte-html'
export const handle = async ({ event, resolve }) => {
// ...
return resolve(event, {
transformPageChunk: apply({
lang: 'en',
prefix: 'example'
})
})
}