studiometa / drupal-project

该软件包已被弃用,不再维护。没有建议的替代软件包。

一个用于启动您的 Drupal 项目的 Composer 项目模板 ⚡

安装: 16

依赖项: 0

建议者: 0

安全: 0

星级: 2

关注者: 9

分支: 0

开放问题: 3

类型:项目

0.1.0 2022-10-27 14:42 UTC

README

安装

克隆存储库

git clone <%= repository %>

安装必要的依赖项

# Installer les dépendances Composer avec PHP 8.0
php8.0 $(which composer) install

# Installer les dépendances NPM avec Node 16
nvm use 16
npm install

开发

可用命令

NPM

命令 描述
npm run dev 启动 SCSS 和 JS 主题文件的编译服务器。
npm run build 构建主题的 SCSS、JS 和 Vue 文件。
npm run lint 使用 ESLint、Stylelint 和 Prettier 对主题的 SCSS、JS、Vue 和 Twig 文件进行 lint。
npm run lint:scripts 使用 ESLint 和 Prettier 对主题的 JS 和 Vue 文件进行 lint。
npm run lint:styles 使用 Stylelint 和 Prettier 对主题的 SCSS 和 Vue 文件进行 lint。
npm run lint:templates 使用 Prettier 对主题的 Twig 文件进行 lint。
npm run fix 使用 ESLint、Stylelint 和 Prettier 格式化主题的 SCSS、JS、Vue 和 Twig 文件。
npm run fix:scripts 使用 ESLint 和 Prettier 格式化主题的 JS 和 Vue 文件。
npm run fix:styles 使用 Stylelint 和 Prettier 格式化主题的 SCSS 和 Vue 文件。
npm run fix:templates 使用 Prettier 格式化主题的 Twig 文件。

Composer

命令 描述
composer phpcs 对主题和自定义模块的 PHP 文件进行 lint。
composer phpstan 静态分析主题和自定义模块的 PHP 文件。
vendor/bin/phpcbf 修正不同文件的 lint 错误,包括 phpcsphpstan 命令。

添加模块

要添加第三方扩展,请使用 Composer。例如,要添加 Search API 插件,可以按照以下步骤操作

composer require drupal/search_api

使用 Drush 激活模块

drush en search_api

Studio Meta 自定义模块

  • studiometa_blocks_manager 用于自定义块的管理。
  • studiometa_display_currentbranch 用于仅在预生产上显示当前 git 分支。
  • studiometa_pages_manager 用于自定义配置页面的管理。
  • studiometa_paragraphs_builder_manager 用于页面构建器和相关段落块的管理。
  • studiometa_twig_extensions 用于 Twig 扩展的管理。

Twig

// Pour importer un atom présent dans le theme (fallback sur le package si non existant)
{% include '@ui/atoms/Button/Button.twig' %}
// Pour importer un atom du package @studiometa/ui
{% include '@ui-pkg/atoms/Button/Button.twig' %}
  • @studiometa/twig-toolkit 已配置用于项目。
  • 区块模板文件遵循以下 命名约定:对于 HeroBlock.php,模板将是 block--meta-hero.html.twig
  • 在每一个 .twig 文件的开头添加一个包含此文件中所有可用变量的注释块。
{#
/**
 * @file
 * Name of the File
 *
 * @param {string} title
 * @param {string} description
 * @param {array} image
 */
#}

Twig 过滤器

// Clean une variable des balises pouvant provoquer des attaques XSS
{{ var|meta_sanitize }}