2017 © Pedro Peláez
 

library crystal-edge

Simple light-weight static website engine

image

mchorse/crystal-edge

Simple light-weight static website engine

  • Tuesday, August 16, 2016
  • by mchorse
  • Repository
  • 2 Watchers
  • 1 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 33 % Grown

The README.md

Crystal Edge

Simple light-weight static website engine wriiten in PHP. Don't use yet, it's not tested and still in development. This is written on iPad in Notes app (seriously)., (*1)

Example

Basic example., (*2)

This code takes all files in current's path content folder, extracts files from content folder, reads the content of those files, process them with Parsedown, replacing the paths from .md to .html extension, and builds those files into ./build directory., (*3)

<?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();

As the result, you get compiled static website from markdown in html in the build folder., (*4)

There's also Wiki available on GitHub (on which I'm working)., (*5)

License

Licensed under MIT license, see LICENSE file., (*6)

The Versions

16/08 2016

dev-master

9999999-dev

Simple light-weight static website engine

  Sources   Download

MIT

The Requires

  • php >=5.4.0