.. include:: /Includes.rst.txt .. _development-webcomponents: ============== Web Components ============== Yoast SEO for TYPO3 provides 13 reusable web components for displaying SEO analysis results, snippet previews, social media previews, and more. These components are React components wrapped as custom elements using ``@r2wc/react-to-web-component``, making them usable in any HTML context. How to import ============= The web components are bundled in a single file that can be imported via the TYPO3 JavaScript module system. The module mapping is configured in ``Configuration/JavaScriptModules.php``: .. code-block:: php return [ 'dependencies' => ['core', 'backend', 'frontend_request'], 'imports' => [ '@yoast/yoast-seo-for-typo3/' => 'EXT:yoast_seo/Resources/Public/JavaScript/', ], ]; To load all web components, import the bundle in your JavaScript module: .. code-block:: javascript import "@yoast/yoast-seo-for-typo3/dist/webcomponents.js" After importing, all ```` custom elements are available for use in HTML. Attribute naming convention =========================== The React components use camelCase property names, which are automatically converted to kebab-case HTML attributes by ``@r2wc/react-to-web-component``. For example: - ``faviconSrc`` becomes ``favicon-src`` - ``wordsToHighlight`` becomes ``words-to-highlight`` - ``readingTime`` becomes ``reading-time`` - ``isLarge`` becomes ``is-large`` Quick reference =============== .. list-table:: :header-rows: 1 :widths: 30 70 * - Component - Attributes * - ```` - *(none)* * - ```` - ``title`` * - ```` - ``description``, ``date`` * - ```` - ``title``, ``url``, ``description``, ``favicon-src``, ``locale``, ``words-to-highlight``, ``site-name``, ``error`` * - ```` - ``analysis-done``, ``result-type``, ``text``, ``score`` * - ```` - ``analysis`` * - ```` - ``keywords`` * - ```` - ``score``, ``difficulty``, ``unsupported-language`` * - ```` - ``reading-time`` * - ```` - ``count``, ``unit`` * - ```` - ``links``, ``is-checking`` * - ```` - ``site-base``, ``title``, ``description``, ``image-url`` * - ```` - ``site-base``, ``title``, ``description``, ``image-url``, ``is-large`` Component reference =================== yoast-loading-spinner --------------------- Displays a loading spinner animation. Used as a placeholder while content is being analysed. This component has no attributes. .. code-block:: html yoast-title-progress-bar ------------------------ Displays a progress bar indicating the SEO title length relative to the recommended character count. .. list-table:: :header-rows: 1 :widths: 20 15 65 * - Attribute - Type - Description * - ``title`` - string - The page title to measure .. code-block:: html yoast-description-progress-bar ------------------------------ Displays a progress bar indicating the meta description length relative to the recommended character count. .. list-table:: :header-rows: 1 :widths: 20 15 65 * - Attribute - Type - Description * - ``description`` - string - The meta description to measure * - ``date`` - string - Optional date string displayed before the description in the preview .. code-block:: html yoast-snippet-preview --------------------- Renders a Google-style SERP (Search Engine Results Page) snippet preview showing how the page would appear in search results. Supports desktop and mobile preview modes. .. list-table:: :header-rows: 1 :widths: 25 15 60 * - Attribute - Type - Description * - ``title`` - string - The page title displayed in the snippet * - ``url`` - string - The page URL displayed in the snippet * - ``description`` - string - The meta description displayed in the snippet * - ``favicon-src`` - string - URL to the site favicon * - ``locale`` - string - Locale string (e.g. ``en_US``) for text direction * - ``words-to-highlight`` - json - JSON array of words to highlight in the description * - ``site-name`` - string - The site name displayed next to the favicon * - ``error`` - json - JSON object with ``url`` and ``statusCode`` properties to display an error state .. code-block:: html yoast-status-icon ----------------- Displays a coloured status indicator (traffic light style) reflecting an SEO or readability score. .. list-table:: :header-rows: 1 :widths: 25 15 60 * - Attribute - Type - Description * - ``analysis-done`` - boolean - Whether the analysis has completed * - ``result-type`` - string - The type of result (e.g. ``seo``, ``readability``) * - ``text`` - boolean - Whether to display the score as text alongside the icon * - ``score`` - number - The numeric score value .. code-block:: html yoast-analysis-result --------------------- Renders the full content analysis results grouped by severity (errors, problems, improvements, considerations, and good results). .. list-table:: :header-rows: 1 :widths: 20 15 65 * - Attribute - Type - Description * - ``analysis`` - json - JSON object containing the analysis results with keys: ``errorsResults``, ``problemsResults``, ``improvementsResults``, ``considerationsResults``, ``goodResults`` .. code-block:: html yoast-insights -------------- Displays a list of prominent words (keywords) found in the content. .. list-table:: :header-rows: 1 :widths: 20 15 65 * - Attribute - Type - Description * - ``keywords`` - json - JSON array of keyword objects to display .. code-block:: html yoast-flesch-reading-score -------------------------- Displays the Flesch Reading Ease score with a visual indicator of the text difficulty. .. list-table:: :header-rows: 1 :widths: 30 15 55 * - Attribute - Type - Description * - ``score`` - number - The Flesch Reading Ease score (0-100) * - ``difficulty`` - number - The difficulty level * - ``unsupported-language`` - boolean - Set when the content language does not support Flesch scoring .. code-block:: html yoast-reading-time ------------------ Displays the estimated reading time for the content. .. list-table:: :header-rows: 1 :widths: 20 15 65 * - Attribute - Type - Description * - ``reading-time`` - number - Estimated reading time in minutes .. code-block:: html yoast-word-count ---------------- Displays the word count for the content. .. list-table:: :header-rows: 1 :widths: 20 15 65 * - Attribute - Type - Description * - ``count`` - number - The number of words * - ``unit`` - string - The unit label to display (e.g. ``words``) .. code-block:: html yoast-linking-suggestions ------------------------- Displays a list of internal linking suggestions for the current page content. .. list-table:: :header-rows: 1 :widths: 20 15 65 * - Attribute - Type - Description * - ``links`` - json - JSON array of link suggestion objects * - ``is-checking`` - boolean - Whether link suggestions are currently being fetched .. code-block:: html yoast-facebook-preview ---------------------- Renders a preview of how the page would appear when shared on Facebook. .. list-table:: :header-rows: 1 :widths: 20 15 65 * - Attribute - Type - Description * - ``site-base`` - string - The base URL of the site * - ``title`` - string - The Open Graph title * - ``description`` - string - The Open Graph description * - ``image-url`` - string - URL to the Open Graph image .. code-block:: html yoast-twitter-preview --------------------- Renders a preview of how the page would appear when shared on X (Twitter). .. list-table:: :header-rows: 1 :widths: 20 15 65 * - Attribute - Type - Description * - ``site-base`` - string - The base URL of the site * - ``title`` - string - The Twitter Card title * - ``description`` - string - The Twitter Card description * - ``image-url`` - string - URL to the Twitter Card image * - ``is-large`` - boolean - Whether to display the large summary card layout .. code-block:: html