jedamzik/statamic-toc
Composer 安装命令:
composer require jedamzik/statamic-toc
包简介
Auto-Generated Table Of Contents from Markdown Fields for Statamic.
README 文档
README
Toc
Auto-Generated Table Of Contents from Markdown Fields for Statamic 3.
This generates a Table Of Contents from a Markdown field.
A list of Headings is saved in the entry as html and can either be rendered directly using {{ table_of_contents }} or through the provided tag {{ toc }} with a customizable wrapper view.
Installation
Require it using Composer.
composer require jedamzik/statamic-toc
Set up a Collection
Publish the wrapper view and package configuration from Njed\Toc\ServiceProvider:
php artisan vendor:publish
Provide a collection handle and a field handle in config/toc.php to activate Toc for a given collection:
return [ 'collections' => [ 'posts' => 'content' ], ... ];
Heading Depth
By default only h1 and h2 are used for the Table of Contents. If you want to include further heading levels, add them to the config:
return [ ... 'includeLevels' => [3, 4] ];
List items for all headings with a level > 2 will have a .child class added so you can style them separately.
Anchor Links for Headings
Items in the Table of Contents can function as anchor links to the heading fragment:
return [ ... 'anchorLinks' => true ];
Linked page fragments are a slugified version of the Heading string (Example Title -> #example-title).
You can extend your Markdown Parser with the provided Njed\Toc\Extensions\CommonMark\TitleAnchorIdExtension to provide these ids for your heading nodes in your rendered views.
To extend the default Parser for all Markdown fields in your Statamic instance, add it to your boot method in the AppServiceProvider:
Markdown::addExtension(function () { return new \Njed\Toc\Extensions\CommonMark\TitleAnchorIdExtension; });
To only use this Extension on a specific Markdown field, you can create a new Parser and specify it for your Markdown field.
Markdown::extend('special', function ($parser) { return $parser ->withStatamicDefaults() ->addExtension(function () { return new \Njed\Toc\Extensions\CommonMark\TitleAnchorIdExtension; }); });
You can set a custom parser for markdown fields either in the control panel or through the parser attribute in your blueprint file:
-
handle: content
field:
...
type: markdown
parser: special
Changelog
Please see CHANGELOG for more information what has changed recently.
License
The MIT License (MIT). Please see License File for more information.
jedamzik/statamic-toc 适用场景与选型建议
jedamzik/statamic-toc 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.12k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 04 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「table of contents」 「statamic」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jedamzik/statamic-toc 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jedamzik/statamic-toc 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jedamzik/statamic-toc 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Plug-ins for DataTables
A component that allows creating responsive HTML tables or lists from data object
Adjacency List’ed Closure Table database design pattern implementation for Laravel. Includes restore of tree
This plugin generates a table of contents from HTML headers in text.
Provides a table of contents for elements based on one or more articles within the page.
Yii2 Articles to create, manage, and delete articles in a Yii2 site.
统计信息
- 总下载量: 2.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-04-15