Kirby3 静态站点生成器使用教程

Kirby3 静态站点生成器使用教程

kirby3-static-site-generatorStatic site generator plugin for Kirby 3+. With this plugin you can create a directory with assets, media and static html files generated from your pages. The result is an even faster site with less potential vulnerabilities.项目地址:https://gitcode.com/gh_mirrors/ki/kirby3-static-site-generator

1. 项目的目录结构及介绍

kirby3-static-site-generator/
├── composer.json
├── composer.lock
├── index.php
├── kirby
├── site
│   ├── blueprints
│   ├── config
│   ├── controllers
│   ├── models
│   ├── snippets
│   ├── templates
│   └── plugins
│       └── static-generator
└── static
  • composer.jsoncomposer.lock:Composer 依赖管理文件。
  • index.php:项目的入口文件。
  • kirby:Kirby CMS 的核心文件夹。
  • site:站点配置和内容文件夹。
    • blueprints:页面蓝图定义。
    • config:配置文件。
    • controllers:控制器文件。
    • models:模型文件。
    • snippets:可重用的代码片段。
    • templates:页面模板。
    • plugins:插件文件夹,包含 static-generator 插件。
  • static:生成的静态站点文件夹。

2. 项目的启动文件介绍

index.php 是项目的入口文件,负责初始化 Kirby CMS 并加载必要的配置和插件。

<?php

require __DIR__ . '/kirby/bootstrap.php';

echo (new Kirby)->render();

3. 项目的配置文件介绍

site/config 文件夹中,通常会有一个 config.php 文件,用于配置 Kirby CMS 和插件。

<?php

return [
    'debug' => true,
    'routes' => [
        [
            'pattern' => 'generate-static-site',
            'action'  => function () {
                $generator = new \Bnomei\StaticSiteGenerator();
                $generator->generate();
                return 'Static site generated.';
            }
        ]
    ],
    'bnomei.statichtml.output' => 'static',
    'bnomei.statichtml.exclude' => [
        'pattern' => '(:all)/generate-static-site'
    ]
];
  • debug:开启调试模式。
  • routes:定义路由,例如生成静态站点的路由。
  • bnomei.statichtml.output:指定生成的静态站点输出文件夹。
  • bnomei.statichtml.exclude:排除某些路由不生成静态页面。

kirby3-static-site-generatorStatic site generator plugin for Kirby 3+. With this plugin you can create a directory with assets, media and static html files generated from your pages. The result is an even faster site with less potential vulnerabilities.项目地址:https://gitcode.com/gh_mirrors/ki/kirby3-static-site-generator

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蔡鸿烈Hope

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值