Stone.js API
    Preparing search index...

    Head/meta management API for React pages, re-exported from the agnostic @stone-js/use-view layer so users import everything from @stone-js/use-react.

    import { createHead } from '@stone-js/use-react'

    class BlogPost implements IPage<ReactIncomingEvent> {
    head ({ data }) {
    return createHead()
    .title(data.post.title)
    .titleTemplate('%s — Stone.js')
    .description(data.post.excerpt)
    .canonical(`https://stonejs.dev/blog/${data.post.slug}`)
    .og({ type: 'article', image: data.post.cover, siteName: 'Stone.js' })
    .twitter({ card: 'summary_large_image', site: '@stonejs' })
    .jsonLd({ '@context': 'https://schema.org', '@type': 'Article', headline: data.post.title })
    .toContext()
    }
    render ({ data }) { return <article>{data.post.body}</article> }
    }
    • Splice a HeadContext into a rendered HTML string (server-side rendering).

      The <title> is replaced in place; everything else is rendered by the agnostic serializeHead (which escapes attribute names/values) and injected at the <!--app-head--> placeholder. Optional <html>/<body> attributes are merged in. All replacements use literal replacers so content containing $&/$'/$1 is inserted verbatim rather than interpreted as a String.replace pattern.

      Parameters

      • head: HeadContext

        The head context to apply.

      • html: string

        The HTML template/string to inject into.

      Returns string

      The HTML string with the head applied.