stakx-io / stakx

An opinionated, powerful, and simple static website generator built in PHP
https://stakx.io/
MIT License
14 stars 3 forks source link

Allow for more complex Repeater PageViews #100

Open allejo opened 5 years ago

allejo commented 5 years ago
Description Value
Status Draft
Target 0.2.1
Breaking Change No

This is a proposal for extending the Repeater PageView behavior to allow for more complex nesting of permalinks. This feature would also be the foundation for supporting pagination at stakx's core.

Summary

---
proj:
  - bzflag:
      proj: "bzflag/%category"
      category:
        - null
        - maps
        - plug-ins
  - jekyll:
      proj: "jekyll/%category"
      category:
        - projects
        - themes
  - libraries
  - stakx
  - web-design
permalink: /projects/%proj/
---

The following Front Matter would generate the following permalinks:

Twig Usage

In each instance of the Repeater PageView, this.iterators would take on the following values:

Detailed Description

At the moment, value expansion only works with an array of strings. This behavior would allow for value expansion to work with associative arrays that allow for further scoped value expansion. When value expansion reaches the "bzflag" value, it will take the value proj and build the permalink off of that.

At this point, we'll have the permalink of /projects/bzflag/%category and because of the scoping, it will then proceed to expand the values of this permalink with the values of projects[0].bzflag.category and generate three permalinks.

Pagination

So how would this specification work with pagination (#72)? Essentially, this would allow for stakx pagination to live at stakx's core with built-in features. Given a blog website, the arbitrary _ has no significant meaning in - _: and is just a way to trigger this special behavior of requiring an associative array versus a string.

These examples are what the FrontMatter would look like internally, the syntax for pagination would be that of #72.

pages:
  - _:
      pages: "%number"
      number:
        - null
        - page2
        - page3
        - page4
permalink: "/blog/%pages"

and given a "group by category" clause, the FrontMatter would look like this:

categories:
  - announcements:
      categories: "announcements/%page"
      page:
        - null
        - page2
        - page3
        - page4
  - unsorted:
      categories: "unsorted/%page"
      page:
        - null
        - page2
permalink: "/blog/category/%categories"