schornio/static-website-generator

服务器上从 Handlebar 模板生成文件

v5.4.0 2021-05-06 12:38 UTC

README

composer require schornio/static-website-generator

脚本

  • sio-swg-compile: 将 ./components 编译为 stdout php 脚本
  • sio-swg-generator: 每个组件都有机会在渲染时运行脚本(generator.phpfunction <component_name>_generator ()
  • sio-swg-render: 用给定的 Storyblok 内容覆盖 ./dist

Handlebar 辅助函数

  • echo
  • join
  • replace
  • toJSON
  • toAlphaNum
  • equal
  • switch
  • case
  • split
  • useDynamic
  • markdown
  • getStory
  • getStories
  • getCurrentStory
  • url
  • resize
  • resolveSlug
  • textToSlug
  • isActiveStory
  • renderTimestamp
  • formatDate
  • storyblokToken
  • (storyblokBridge)

图像处理器必须位于 public/images

RewriteCond %{REQUEST_URI} ^/public/images/.+
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ public/imageProcessor.php [L]

静态(.html)和动态(.php)内容之间的区别

hbs-helper {{useDynamic}} 标记模板为动态内容。如果渲染链中至少有一个模板被标记为动态,则生成的文件将以 .php 结尾,而不是 .html

{{useDynamic}}

<?php
// Dynamic content here

$data = json_decode("{{{toJSON data}}}");

?>

特殊的 slug --fileextension-

如果 slug 包含 (filename)--fileextension-(extension),则文件将被存储为 (filename).(extension)。例如,sitemap--fileextension-xml 将被转换为 sitemap.xml