Give pages starting with a underscore (_) a special treatment
Follow-up to b493ebdb84
This commit is contained in:
parent
9a2dd4f078
commit
9b72b5c316
4 changed files with 30 additions and 16 deletions
12
content-sample/_meta.md
Normal file
12
content-sample/_meta.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
social:
|
||||
- title: Visit us on GitHub
|
||||
url: https://github.com/picocms/Pico
|
||||
icon: octocat
|
||||
- title: Check us out on Twitter
|
||||
url: https://twitter.com/gitpicocms
|
||||
icon: birdy
|
||||
- title: Join us on Freenode IRC Webchat
|
||||
url: https://webchat.freenode.net/?channels=%23picocms
|
||||
icon: chat
|
||||
---
|
|
@ -1,16 +1,6 @@
|
|||
---
|
||||
Title: Welcome
|
||||
Description: Pico is a stupidly simple, blazing fast, flat file CMS.
|
||||
social:
|
||||
- title: Visit us on GitHub
|
||||
url: https://github.com/picocms/Pico
|
||||
icon: octocat
|
||||
- title: Check us out on Twitter
|
||||
url: https://twitter.com/gitpicocms
|
||||
icon: birdy
|
||||
- title: Join us on Freenode IRC Webchat
|
||||
url: https://webchat.freenode.net/?channels=%23picocms
|
||||
icon: chat
|
||||
---
|
||||
|
||||
## Welcome to Pico
|
||||
|
|
20
lib/Pico.php
20
lib/Pico.php
|
@ -344,8 +344,11 @@ class Pico
|
|||
// load raw file content
|
||||
$this->triggerEvent('onContentLoading', array(&$this->requestFile));
|
||||
|
||||
$notFoundFile = '404' . $this->getConfig('content_ext');
|
||||
if (file_exists($this->requestFile) && (basename($this->requestFile) !== $notFoundFile)) {
|
||||
if (
|
||||
file_exists($this->requestFile)
|
||||
&& (basename($this->requestFile) !== '404' . $this->getConfig('content_ext'))
|
||||
&& !preg_match('/(?:^|\/)_/', $this->requestFile)
|
||||
) {
|
||||
$this->rawContent = $this->loadFileContent($this->requestFile);
|
||||
} else {
|
||||
$this->triggerEvent('on404ContentLoading', array(&$this->requestFile));
|
||||
|
@ -1294,6 +1297,7 @@ class Pico
|
|||
'time' => &$meta['time'],
|
||||
'date' => &$meta['date'],
|
||||
'date_formatted' => &$meta['date_formatted'],
|
||||
'hidden' => (bool) preg_match('/(?:^|\/)_/', $id),
|
||||
'raw_content' => &$rawContent,
|
||||
'meta' => &$meta
|
||||
);
|
||||
|
@ -1331,6 +1335,10 @@ class Pico
|
|||
}
|
||||
|
||||
$alphaSortClosure = function ($a, $b) use ($order) {
|
||||
if ($a['hidden'] xor $b['hidden']) {
|
||||
return (!!$a['hidden'] - !!$b['hidden']) * (($order === 'desc') ? -1 : 1);
|
||||
}
|
||||
|
||||
$aSortKey = (basename($a['id']) === 'index') ? dirname($a['id']) : $a['id'];
|
||||
$bSortKey = (basename($b['id']) === 'index') ? dirname($b['id']) : $b['id'];
|
||||
|
||||
|
@ -1341,8 +1349,12 @@ class Pico
|
|||
if ($orderBy === 'date') {
|
||||
// sort by date
|
||||
uasort($this->pages, function ($a, $b) use ($alphaSortClosure, $order) {
|
||||
if (empty($a['time']) || empty($b['time'])) {
|
||||
$cmp = (empty($a['time']) - empty($b['time']));
|
||||
if ($a['hidden'] xor $b['hidden']) {
|
||||
return $alphaSortClosure($a, $b);
|
||||
}
|
||||
|
||||
if (!$a['time'] || !$b['time']) {
|
||||
$cmp = (!$a['time'] - !$b['time']);
|
||||
} else {
|
||||
$cmp = ($b['time'] - $a['time']);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
</h1>
|
||||
<div id="nav" role="region" tabindex="-1">
|
||||
<ul>
|
||||
{% for page in pages if page.title and not (page.id starts with "_") %}
|
||||
{% for page in pages if page.title and not page.hidden %}
|
||||
{% set pageDepth = page.id|split('/')|length %}
|
||||
{% if (pageDepth == 2) and (page.id ends with "/index") or (pageDepth == 1) %}
|
||||
<li{% if page.id == current_page.id %} class="active"{% endif %}>
|
||||
|
@ -50,7 +50,7 @@
|
|||
<div id="footer">
|
||||
<div class="container">
|
||||
<div class="social">
|
||||
{% for social in meta.social %}
|
||||
{% for social in pages._meta.meta.social %}
|
||||
<a href="{{ social.url }}" title="{{ social.title }}" role="button">
|
||||
<span class="icon-{{ social.icon }}" aria-hidden="true"></span>
|
||||
<span class="sr-only">{{ social.title }}</span>
|
||||
|
|
Loading…
Reference in a new issue