mchorse/crystal-edge

简单的轻量级静态网站引擎

dev-master 2016-08-16 11:00 UTC

This package is not auto-updated.

Last update: 2024-09-15 00:38:52 UTC


README

简单的轻量级静态网站引擎,用PHP编写。尚未使用,尚未测试,仍在开发中。这是在iPad的笔记应用中编写的(认真地说)。

示例

基本示例。

此代码将当前路径下content文件夹中的所有文件提取出来,读取这些文件的内容,使用Parsedown进行处理,将路径从.md替换为.html扩展名,并将这些文件构建到./build目录中。

<?php

/* Crystal Edge's imports */
use crystal\edge\FileSystemExport;
use crystal\edge\FileSystemExtract;
use crystal\edge\Site;

/* Website plugins */

/** Only markdown files */
$only_md = crystal\edge\filter(function($_, $path)
{
  return preg_match('/\.md$/', $path);
});

/** Read files from FS */
$read = crystal\edge\apply('path', 'content', 'file_get_contents');

/** Convert markdown into HTML */
$parsedown = crystal\edge\apply('content', 'output', [new Parsedown, 'text']);

/** Replace markdown with html extension */
$extension = crystal\edge\remap(function($key)
{
  return str_replace('.md', '.html', $key);
});

/* Website */
$site = new Site(new FileSystemExtract('./content/'));
$site->plugins = [$only_md, $read, $parsedown, $extension];

/* Build and ship it */
(new FileSystemExport($site, './build/'))->export();

结果,您将在build文件夹中获得从markdown编译的静态网站html。

GitHub上也有Wiki(我在上面工作):GitHub

许可

根据MIT许可证授权,请参阅LICENSE文件。