longitude-one/meta-bundle

用于管理元标签的Symfony包

1.0.2 2022-04-07 16:44 UTC

This package is auto-updated.

Last update: 2024-09-07 22:23:50 UTC


README

此包提供了一个Twig扩展和一个易于配置的文件,用于自定义所有元标签的内容。

安装

composer require longitude-one/meta-bundle

配置

编辑您的twig基础视图以调用我们twig扩展实现的函数meta_description()meta_title()meta('foo:bar')

示例

<!-- templates/base.html.twig -->
<!DOCTYPE html>
<html lang="fr">
<head>
    <meta name="description" content="{{ meta_description() }}" />
    <meta property="og:image" content="{{ meta('og:image') }}" />
    <title>{{ meta_title() }}</title>
</head>
<body></body>
</html>

创建或编辑包配置文件,并

# config/packages/meta.yaml
meta:
  defaults:
    description: 'My default description' # the default description
    'og-image': 'My default image' # the default image
    title: 'My default title' # the default title
  paths:
    '/foo/bar/': # For this url, our extension will return customs 
      description: 'My custom description for /foo/bar url'
      'og-image': 'My custom image for /foo/bar url'
      title: 'My custom title for /foo/bar url'
    '/bar': #For this url, our extension will return a custom title and the default image and title.
      title: 'My custom description for /bar url'

贡献

  • Fork github项目。
  • 克隆它

嵌入了一个非常简单的docker,以

  • 提供PHP8.1环境
  • 提供composer、symfony和phpcsfixer作为外部工具
  • 启动本地symfony服务器以帮助您进行开发

然后简单地构建您的容器

docker-compose up --build

通过您的浏览器,您可以通过访问symfony本地服务器http://127.0.0.1/来访问嵌入的应用程序

更新代码,修复错误或实现新功能,然后检查测试。

docker exec bundle-php ./vendor/bin/phpunit

使用PHP-CS-FIXER检查代码质量

docker exec bundle-php tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=tools/php-cs-fixer/.php-cs-fixer.php

一切正常?提交您的代码,推送并拉取请求;)