You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+59-25Lines changed: 59 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,41 +15,75 @@ The CMS was built to be as streamlined and stripped-down as possible, so it's me
15
15
# File Structure
16
16
There are 2 directories for content, `pages` and `layouts`, and just one file for configuration, `config.json`.
17
17
18
+
## Pages
18
19
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
+
```
19
26
27
+
## Layouts
20
28
The `layouts` directory stores layout templates and their assets. The default global theme is set in `config.json` on the `layout` property.
21
29
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
+
22
38
# Routes
23
39
Routes are defined separately from pages to easily manage the content and access of each route.
24
40
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",
|`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|
31
62
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.
36
65
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|
38
74
39
-
## config.json
75
+
#Config.json
40
76
```json
41
77
{
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": {}
54
82
}
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