ianreid / iconlibrairies
SVG图标库与Craft CMS原生SVG功能的集成。
1.0
2023-10-04 17:34 UTC
Requires
- craftcms/cms: ^3.0|^4.0
Requires (Dev)
- craftcms/rector: dev-main
This package is auto-updated.
Last update: 2024-09-12 18:00:28 UTC
README
Craft CMS图标库
轻松集成各种SVG图标库与Craft CMS原生SVG功能。
要求
此插件需要Craft CMS 4.x或更高版本
安装
要安装此插件,请按照以下说明操作。
-
在您的终端中,进入Craft项目目录
cd /path/to/project
-
使用Composer加载并安装插件
composer require ianreid/iconlibrairies -w && php craft plugin/install icon-librairies
使用方法
要使用提供的库中的SVG,您可以直接使用Craft CMS的原生SVG功能
{{ svg('@phosphor/shield.svg')|attr({ class: 'w-8 h-8 text-gray-500' }) }}
示例:使用phosphor图标库中的一个图标
{{ svg('@heroicons/o-arrow-right.svg')|attr({ class: 'w-8 h-8 text-green-500' }) }}
可用图标库
SVG净化和命名空间
默认情况下,如果您使用原生SVG功能,SVG将通过svg-sanitizer净化潜在有害的脚本,并且文档内的任何ID或类名都将进行命名空间处理,以避免与DOM中的其他ID或类名冲突。您可以使用sanitize
和namespace
参数来禁用
这些行为
{{ svg('@phosphor/shield.svg', sanitize=false, namespace=false) }}
此插件由Ian Reid Langevin提供