matthiasjg/kirby3-static-site-composer

Kirby 3 静态网站作曲家

dev-main 2022-10-29 13:24 UTC

This package is auto-updated.

Last update: 2024-09-29 05:56:33 UTC


README

为构建(作曲)静态网站而设计的 Kirby 3 插件。

本质上是一个包装器,用于集成和触发合适的社区插件

  1. 静态网站生成器
  2. 订阅

在 Kirby 3 控制面板中字段初始状态的截图

从成功运行的结果中字段的截图

安装

下载

下载并将此存储库复制到 /site/plugins/static-site-composer

Git 子模块

git submodule add https://github.com/matthiasjg/kirby3-static-site-composer.git site/plugins/static-site-composer

Composer

composer require matthiasjg/kirby3-static-site-composer

设置

有关如何配置插件(例如蓝图设置和配置选项)的说明。

蓝图字段

# site/blueprints/site.yml
fields:
  staticSiteComposer:
    label: Compose
    # help: Click here to compose a static version of the website of pages and feeds.
    # progress: Please wait, composing site...
    # success: Static site successfully composed.
    # error: An error occurred

配置选项

此插件配置了以下选项

# site/config/config.php
return [
  'matthiasjg' => [
    'static_site_composer' => [
      'endpoint'                  => 'compose-static-site', # set to any string like 'compose-static-site' to use the built-in endpoint (mandatory when using the blueprint field)
      'output_folder'             => './static', # you can specify an absolute or relative path
      'preserve'                  => [], # preserve individual files / folders in the root level of the output folder (anything starting with "." is always preserved)
      'base_url'                  => '/', # if the static site is not mounted to the root folder of your domain, change accordingly here
      'skip_media'                => false, # set to true to skip copying media files, e.g. when they are already on a CDN; combinable with 'preserve' => ['media']
      'skip_templates'            => [], # ignore pages with given templates (home is always rendered)
      'pages_parent_home_root'    => false, # copy pages w/ parent=site.homePage from home/* to root /*
      'preview_url_slug'               => 'preview' # the blueprint option.preview: for site (e.g. "/preview/home"), page (e.g. "/preview{{ page.parent.url }}/{{ page.slug }}") or post (e.g. "/preview/{{ page.parent.slug }}/{{ page.slug }}") 
      'feed_formats'              => ['rss', 'json'], # format of feeds  
      'feed_description'          => 'Latest posts from the blog', # description for feed
      'feed_collection'           => 'posts', # collection for feed items
      'feed_collection_limit'     => 10, # number of collection items in feed
      'feed_collection_datefield' => 'date', # date field from collection
      'feed_collection_textfield' => 'text' # text field from collection
    ]
  ]
];

HTML 模板

<!-- RSS Feed -->
<link rel="alternate" type="application/rss+xml"  href="<?= site()->url() ?>/feed.rss"  title="<?= $site->title()->html() ?> RSS Feed">

<!-- JSON Feed -->
<link rel="alternate" type="application/json"     href="<?= site()->url() ?>/feed.json" title="<?= $site->title()->html() ?> JSON Feed">

API

也可以触发端点 matthiasjg.static_site_composer.endpoint,例如 这样

许可证

MIT

致谢