Componette

Componette

nepada

nepada / meta-control v1.5.1

Nette control for managing meta data in HTML header.

download-cloud-line composer require nepada/meta-control

Meta Control

Build Status Coverage Status Downloads this Month Latest stable

Installation

Via Composer:

$ composer require nepada/meta-control

Usage

First register the control factory in your config and optionally set up default metadata:

services:
    -
        implement: Nepada\MetaControl\MetaControlFactory
        setup:
            - setCharset('utf-8')
            - setAuthor('Jon Doe')

Use the control factory in your presenter:

protected function createComponentMeta(): Nepada\MetaControl\MetaControl
{
    $control = $this->metaControlFactory->create();
    $control->setDescription('Lorem ipsum');
    return $control;
}

And render it in your Latte template:

<html>
<head>
    {control meta}
</head>
<body>
    ...
</body>
</html>

Overview of supported meta tags

Charset:

// <meta charset="utf-8">
$control->setCharset('utf-8');
$control->getCharset(); // 'utf-8'

Document metadata:

// <meta name="author" content="John Doe">
$control->setMetadata('author', 'Jon Doe');
$control->getMetadata('author'); // 'Jon Doe'

Document properties:

// <meta property="og:title" content="Foo title">
$control->setProperty('og:title', 'Foo title');
$control->getProperty('og:title'); // 'Foo title'

Pragma directives:

// <meta http-equiv="content-type" content="text/html; charset=UTF-8">
$control->setPragma('content-type', 'text/html; charset=UTF-8');
$control->getPragma('content-type'); // 'text/html; charset=UTF-8'

Shorthands for standard metadata

Author:

// <meta name="author" content="John Doe">
$control->setAuthor('Jon Doe');
$control->getAuthor(); // 'Jon Doe'

Description:

// <meta name="description" content="Lorem ipsum">
$control->setDescription('Lorem ipsum');
$control->getDescription(); // 'Lorem ipsum'

Keywords:

// <meta name="keywords" content="foo, bar, baz">
$control->setKeywords('foo', 'bar');
$control->addKeyword('baz');
$control->getKeywords(); // ['foo', 'bar', 'baz']

Robots:

// <meta name="robots" content="noindex, nofollow">
$control->setRobots('noindex, nofollow');
$control->getRobots(); // 'noindex, nofollow'
  • v1.5.1 1.5.1

    • PHP 8.4 compatibility
  • v1.5.0 1.5.0

    • Drop support for PHP <8.1
    • PHP 8.3 compatibility
  • v1.4.2 1.4.2

    • Support nette/utils 4
  • v1.4.1 1.4.1

    • PHP 8.2 compatibility
  • v1.4.0 1.4.0

    • PHP 8.1 compatibility.
  • v1.3.0 1.3.0

    • PHP 8.0 compatiblity.
  • v1.2.1 1.2.1

    • Dropped interface prefix:
      • Nepada\MetaControl\IMetaControlFactory is deprecated, use Nepada\MetaControl\MetaControlFactory instead
  • v1.2.0 1.2.0

    • Requires PHP >=7.4.
    • Uses native property typehints.
  • v1.1.0 1.1.0

    • Requires PHP >=7.2.
    • PHP 7.4 compatibility.
    • Requires Nette 3.0 (Nette 2.4 support was dropped).
  • v1.0.2 1.0.2

    • Nette 3 support.
    • CI improvements.
  • v1.0.0 1.0.0

    • Initial release.
  • v1.0.1 1.0.1

    • Allow nette/utils 3.x.
    • Code style improvements.
price-tag-2-line

Badges

guide-fill

Dependencies

php (>=7.1.0)
nette/utils (^2.4@dev || ^3.0@dev)
nette/application (^2.4@dev || ^3.0@dev)
Componette Componette felix@nette.org