GitHub

DaffSchemaService

import { DaffSchemaService } from '@daffodil/seo'

A service for managing JSON-LD schema tags in a document.

There is only ever one schema tag per document, multiple schemas can be added by calling upsert with an array.

The schema data can be found via a script tag with the id daff-schema in the document.

@Injectable()
class DaffSchemaService<<T>>  {
  readonly selector: "daff-schema" = 'daff-schema'
  get scriptTag(): HTMLScriptElement

  getSchema(): string
  upsert(schema: Schema<T>): void
  remove(): void
}

Properties

selector
"daff-schema"
Default'daff-schema'
Description
scriptTag
HTMLScriptElement
Default
Description

Memoized schema script tag.

() Methods

getSchema
string

The string represenation of the schema.

WARNING: This content is comes directly from the DOM. It could contain malicious content, be very careful with what you do with it.

upsert
void

Either creates a new schema tag in the document, or updates the existing schema tag in the document.

Parameters
Parameterschema: Schema
Description
remove
void

Removes the schema from the document.