Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
taufik-nurrohman committed May 22, 2022
1 parent d816682 commit a32773b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
9 changes: 5 additions & 4 deletions about.page
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Layout
description: Common automation function used to speed up site development.
description: Common automation features to speed up the site creation process.
icon: 'M13,3V9H21V3M13,21H21V11H13M3,21H11V15H3M3,13H11V3H3V13Z'
author: Taufik Nurrohman
type: Markdown
Expand All @@ -9,6 +9,7 @@ version: 2.0.0

### Features

- Detect asset path relative to the `.\lot\asset` and `.\lot\y\*` folder.
- Detect layout path relative to the `.\lot\y\*` folder.
- Add HTML classes automatically to the `<html>` element based on the current page conditional statements.
- Add HTML classes automatically to the `<html>` element based on the current page conditional statements.
- Custom layout path using page’s `layout` property.
- Detect asset path relative to the `.\lot\y\*` folder.
- Detect layout path relative to the `.\lot\y\*` folder.
18 changes: 16 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function content($content) {
$r = new \HTML($m[0]);
$c = true === $r['class'] ? [] : \preg_split('/\s+/', $r['class'] ?? "");
$c = \array_unique(\array_merge($c, \array_keys(\array_filter((array) \State::get('[y]', true)))));
\sort($c);
\sort($c); // Sort class name(s)
$r['class'] = \trim(\implode(' ', $c));
return $r;
}
Expand All @@ -34,9 +34,12 @@ function content($content) {
return $content;
}
function get() {
if (!\class_exists("\\Asset")) {
return;
}
foreach ($GLOBALS['Y'][1] ?? [] as $use) {
// Detect relative asset path to the `.\lot\y\*` folder
if (\class_exists("\\Asset") && $assets = \Asset::get()) {
if ($assets = \Asset::get()) {
foreach ($assets as $k => $v) {
foreach ($v as $kk => $vv) {
// Full path, no change!
Expand All @@ -59,6 +62,17 @@ function get() {
function route($content, $path) {
\ob_start();
\ob_start("\\ob_gzhandler");
if (\is_array($content) && \class_exists("\\Page")) {
$page = $GLOBALS['page'] ?? new \Page;
if ($page && $page instanceof \Page && ($layout = $page->layout)) {
// `$content = ['.\lot\y\log\page\gallery.php', [], 200];`
if (0 === \strpos($layout, ".\\")) {
$layout = \stream_resolve_include_path(\PATH . \D . \strtr(\substr($layout, 2), ["\\" => \D]));
}
// `$content = ['page/gallery', [], 200];`
$content[0] = $layout;
}
}
// `$content = ['page', [], 200];`
if (\is_array($content) && isset($content[0]) && \is_string($content[0])) {
if ($r = \Layout::get(...$content)) {
Expand Down

0 comments on commit a32773b

Please sign in to comment.