Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

Latest commit

 

History

History
202 lines (136 loc) · 4.43 KB

README.md

File metadata and controls

202 lines (136 loc) · 4.43 KB

[DEPRECATED since 2020-03] Statie - Modern and Simple Static Site Generator in PHP

Downloads

Statie takes HTML, Markdown and Twig files and generates static HTML page.

Install

composer require symplify/statie

How to Generate and See the Website?

  1. Prepare content for Statie
vendor/bin/statie init

This will generate config, templates, layouts and gulp code, so you can enjoy live preview.

Last step is install node dependencies:

npm install
  1. Generate static site from /source (argument) to /output (default value) in HTML:
vendor/bin/statie generate source
  1. Run website locally
gulp
  1. And see web in browser localhost:8000.

Do you use Jekyll or Sculpin?

Configuration

statie.yml Config

This is basically Symfony Kernel config.yml that you know from Symfony application. You can:

# statie.yml
imports:
    - { resource: 'data/favorite_links.yml' }

parameters:
    site_url: 'http://github.com'
    socials:
        facebook: 'http://facebook.com/github'

services:
    App\SomeService: ~

Parameters are available in every template:

{# source/_layouts/default.twig #}

<p>Welcome to: {{ site_url }}</p>

<p>Checkout my FB page: {{ socials.facebook }}</p>

Do You Write Posts?

Create a new empty .md file with date, webalized title and ID:

vendor/bin/statie create-post "My new post"

Statie privides default template:

id: __ID__
title: "__TITLE__"
---

Do you want your own template? Configure path to it:

# statie.yaml
parameters:
    post_template_path: 'templates/my_own_post.twig'

That's it!

How to Generate API?

Statie web Friendsofphp.org provide info about PHP meetups and groups. They're already stored in parameters. Do you want to publish them as JSON API?

parameters:
    api_parameters:
        - 'groups'
        - 'meetups'

This will generate 2 pages:

/api/groups.json
/api/meetups.json

With parameters as JSON, that anyone can use now.

How to Redirect old page?

# statie.yml
parameters:
    redirects:
        old_page: 'new_page'
        old_local_page: 'https://external-link.com'

Are you Speaker? Use your JoindIn Talks

# statie.yml
parameters:
    joind_in_username: 'tomasvotruba'
vendor/bin/statie dump-joind-in

This will generated source/_data/generated/joind_in_talks.yaml file with your talks:

parameters:
    joind_in_talks:
        # ...

Then you can use them like any other parameter in your Statie templates:

{% for joind_in_talk in joind_in_talks %}
    ...
{% endfor %}

Useful Twig Filters

All from this basic set and more:

{% set users = sort_by_field(users, 'name') %}
{% set users = sort_by_field(users, 'name', 'desc') %}

<!-- picks all posts defined in "related_items: [1]" in post -->
{% set relatedPosts = related_items(post)}

{{ content|reading_time }} mins
{{ post.getRawContent|reading_time }} mins

{{ perexDeprecated|markdown }}
{% set daysToFuture = diff_from_today_in_days(meetup.startDateTime) %}

{{ post|link }}

Documentation

Thanks to @crazko you can enjoy neat documentation and see projects that use Statie at statie.org.

Contributing

Open an issue or send a pull-request to main repository.