Skip to content

Commit 55123ce

Browse files
author
jpmoormann
committed
updated docs
1 parent 7032d2e commit 55123ce

File tree

1 file changed

+59
-25
lines changed

1 file changed

+59
-25
lines changed

README.md

Lines changed: 59 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,75 @@ The CMS was built to be as streamlined and stripped-down as possible, so it's me
1515
# File Structure
1616
There are 2 directories for content, `pages` and `layouts`, and just one file for configuration, `config.json`.
1717

18+
## Pages
1819
The `pages` directory stores all the content for the site, and can be referenced as a file path on the `page` property to render the page for a route.
20+
```
21+
🗀 pages
22+
🗋 home.php
23+
🗋 about.php
24+
🗋 404.php
25+
```
1926

27+
## Layouts
2028
The `layouts` directory stores layout templates and their assets. The default global theme is set in `config.json` on the `layout` property.
2129

30+
Each layout directory must have a `index.php` file and an `assets` directory. You can organize your CSS, JavaScript, fonts, and images within the `assets` directory as you see fit.
31+
```
32+
🗀 layouts
33+
🗀 layoutName
34+
🗀 assets
35+
🗋 index.php
36+
```
37+
2238
# Routes
2339
Routes are defined separately from pages to easily manage the content and access of each route.
2440

25-
Each route is defined as a key on the `routes` property in `config.json`, and value is an object whose properties define the route's metadata and page content.
26-
27-
There is an optional `layout` property to render the page with a different layout template than the global default, or without one at all by setting it to `false`.
28-
29-
# Layouts
30-
Each layout directory must have a `index.php` file and an `assets` directory. You can organize your CSS, JavaScript, fonts, and images within the `assets` directory as you see fit.
41+
## Route Properties
42+
Each route is defined as a key on the `routes` property in `config.json` whose value is an object with properties that define the route's metadata and page content.
43+
```json
44+
{
45+
"routes": {
46+
"/": {
47+
"title": "Page Title",
48+
"desc": "This is a description of the page for SEO",
49+
"img": "https://domain.com/path/to/image/for/seo.jpg",
50+
"page": "pages/page.php",
51+
"body": "Some text"
52+
}
53+
}
54+
}
55+
```
56+
|Name|Data Type|Required?|Note|
57+
|---|---|---|---|
58+
|`title`|`string`|Yes|Page title|
59+
|`page`|`string`|Conditional|Required if `body` not set. Overwrites `body` value with rendered content|
60+
|`body`|`string`|Conditional|Required if `page` not set|
61+
|`layout`|`string`|No|If set to valid path, will override default `layout`. If set to false, no layout is used|
3162

32-
A handful of global variables are available for use in the `index.php` of a layout:
33-
- `(object) $config` -> the site config object
34-
- `(string) $assets` -> absolute URI to reference CSS, JavaScript, images, etc.
35-
- `(object) $page` -> the current page object, which contains metadata and rendered content
63+
# Templating
64+
Jerpy relies on the built-in templating functionality of PHP, so use `include` and `require` as you would normally, parsing content as needed, i.e. using [Parsedown](https://github.com/erusev/parsedown) or other utilities.
3665

37-
# Documentation
66+
## Global Variables
67+
There are 4 global variables you can use in a layout or page file: `$config`, `$req`, `$page`, and `$assets`.
68+
|Name|Data Type|Note|
69+
|---|---|---|
70+
|`$config`|`object`|The stdClass object of `config.json`|
71+
|`$req`|`object`|The current request, contains properties `path` (string of URI) and `query` (associative array of URL query parameters)|
72+
|`$page`|`object`|Contains the body content, as well as a `meta` property that inherits all the properties defined by the route object|
73+
|`$assets`|`string`|Absolute path to the current layout's assets directory|
3874

39-
## config.json
75+
# Config.json
4076
```json
4177
{
42-
"siteName": "My Site", // string: can be used in layout
43-
"maintenance": true, // bool: toggle site-wide maintenance mode; returns HTTP 503 for all routes
44-
"layout": "default", // string: default global layout
45-
"routes": { // object: key->value store of all routes
46-
"/": { // string: route URI
47-
"title": "Home", // string: metadata title
48-
// add any additional metadata/OpenGraph string properties for SEO (i.e., $page->meta->title in layout)
49-
"page": "pages/home.php", // string: use this to render a page file (takes preference over body)
50-
"body": "Hello, World!", // string(optional): or use this to specify a raw response body (used if page not defined)
51-
"layout": false // string|bool(optional): used to override the default global layout; set to false for no layout
52-
}
53-
}
78+
"siteName": "My Site",
79+
"maintenance": false,
80+
"layout": "default",
81+
"routes": {}
5482
}
55-
```
83+
```
84+
|Name|Data Type|Note|
85+
|---|---|---|
86+
|`siteName`|`string`|Name for site|
87+
|`maintenance`|`boolean`|Toggle site-wide maintenance mode. When true, returns HTTP 503 for all routes|
88+
|`layout`|`string`|The default layout to use for routes|
89+
|`routes`|`object`|Key:value object of all defined routes|

0 commit comments

Comments
 (0)