nepada / meta-control
Nette control for managing meta data in HTML header.
Installs: 3 241
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=8.1.0 <8.5
- nette/application: ^3.1.4@dev
- nette/utils: ^3.2@dev || ^4.0@dev
Requires (Dev)
- composer-runtime-api: ^2.0
- composer/semver: 3.4.3
- nepada/coding-standard: 7.14.0
- nepada/phpstan-nette-tester: 1.2.1
- nette/http: *@dev
- nette/tester: 2.5.4
- php-parallel-lint/php-parallel-lint: 1.4.0
- phpstan/phpstan: 1.12.5
- phpstan/phpstan-nette: 1.3.8
- phpstan/phpstan-strict-rules: 1.6.1
- shipmonk/phpstan-rules: 3.2.1
- spaze/phpstan-disallowed-calls: 3.4.0
This package is auto-updated.
Last update: 2024-10-27 17:08:23 UTC
README
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'