datashaman / tongs
Laravel 的类似 Metalsmith 的工具。
Requires
- php: ^7.2
- erusev/parsedown: ^1.7
- illuminate/log: ^6.0
- illuminate/pipeline: ^6.12
- illuminate/view: ^6.12
- laravel-zero/framework: ^6.0
- symfony/filesystem: ^4.0
- symfony/finder: ^4.3.4
- symfony/process: ^4.3
- webuni/front-matter: ^1.1
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: ^8.0
README
使用 Laravel Zero 的静态网站生成器。高度基于 metalsmith。正在进行中。
示例网站
示例网站的源代码位于 datashaman/tongs-example。
构建的文件部署在 tongs-example.datashaman.com。
源和目标
source
和 destination
配置可以是字符串或 Laravel 文件系统的配置数组。
如果是一个字符串,将创建一个 本地 文件系统,其根目录设置为 directory
/source
值,其中 directory
将是命令行应用程序当前工作目录。
例如
{
"source": "src",
"destination": {
"driver": "s3",
"region": "eu-west-1",
"bucket": "example.com"
}
}
将从 src
目录构建到名为 example.com
的 S3 桶的根目录,使用默认的 AWS 凭据。
插件
以下插件由本包提供
集合
通过在前面材料中添加 collection
值或在匹配文件中添加 pattern
(它使用 fnmatch)将帖子添加到 collections
元数据中。
例如
{
"plugins": {
"collections": {
"posts": "posts/*.html",
"other": {
"pattern": "other/*.html"
}
}
}
}
将在元数据中创建两个集合在 $collections['posts']
和 $collections['other']
。如果您还向帖子前面材料添加 collection: featured
,您可以在 $collections['featured']
访问这些帖子的集合。
草稿
将帖子标记为草稿,以便它们不会被构建。
例如
{
"plugins": {
"drafts": truu
}
}
将删除前面材料中带有 draft: true
的帖子。
Markdown
将 Markdown 文件渲染为 HTML。
例如
{
"plugins": {
"markdown": {
"breaksEnabled": true,
"strictMode": true
}
}
}
将使用 Parsedown 解析器将内容从 Markdown 转换为 HTML(并重命名文件)。配置对象被混淆以创建对解析器的配置调用。
例如,上面的配置将配置解析器使用 setBreaksEnabled(true)
和 setStrictMode(true)
。请参阅 源代码 了解选项。
视图
使用 Blade 视图将视图和布局渲染为 HTML。
例如
{
"plugins": {
"views": {
"paths": [
"views"
],
"compiled": ".cache"
}
}
}
在帖子中放置 view: post
前面材料,它将使用 Blade 从 views/post.blade.php
渲染。本地视图变量由帖子前面材料和全局元数据值组成。
更多插件包
feed
在 datashaman/tongs-feedmetadata
在 datashaman/tongs-metadatamore
在 datashaman/tongs-morepermalinks
在 datashaman/tongs-permalinkssass
在 datashaman/tongs-sass
要创建自己的插件,请参阅 插件模板。