This commit is contained in:
parent
41640e0b28
commit
b36abcd3bf
12 changed files with 86 additions and 8 deletions
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
return function ($page, $tag, $category) {
|
||||
use Kirby\Cms\Page;
|
||||
|
||||
return function (Page $page, ?string $tag, ?string $category): array {
|
||||
$articles = $page->children()->listed();
|
||||
|
||||
if ($tag) {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
return function ($page) {
|
||||
use Kirby\Cms\Page;
|
||||
|
||||
return function (Page $page): array {
|
||||
return [
|
||||
'quotes' => $page->children()->listed()->flip()->paginate(20)
|
||||
];
|
||||
|
|
|
@ -1,19 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\Page;
|
||||
|
||||
/**
|
||||
* @method object categories()
|
||||
* @method object tags()
|
||||
* @method object date()
|
||||
* @method object text()
|
||||
*/
|
||||
class ArticlePage extends Page
|
||||
{
|
||||
private const READING_TIME_FORMAT = '%d words, ~%d min reading time';
|
||||
|
||||
/**
|
||||
* @param array|string|null $options
|
||||
*/
|
||||
public function url($options = null): string
|
||||
{
|
||||
$date = $this->date()->toDate('Y/m/d');
|
||||
return '/' . $date .'/' . $this->slug();
|
||||
}
|
||||
|
||||
public function readingTime() {
|
||||
public function readingTime(): string
|
||||
{
|
||||
$doc = new DOMDocument();
|
||||
$doc->loadHtml(
|
||||
"<html><head><meta charset=\"UTF-8\"><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></head><body>"
|
||||
$doc->loadHTML(
|
||||
'<html><head><meta charset="UTF-8"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body>'
|
||||
. $this->text()->kirbytext()
|
||||
."</body></html>"
|
||||
. '</body></html>'
|
||||
);
|
||||
$pElems = $doc->getElementsByTagName('p');
|
||||
|
||||
|
@ -25,6 +39,6 @@ class ArticlePage extends Page
|
|||
$wordCount = count(explode(' ', $text));
|
||||
$readingTime = (int)ceil($wordCount / 150);
|
||||
|
||||
return $wordCount . ' words, ~' . $readingTime . 'min reading time';
|
||||
return sprintf(self::READING_TIME_FORMAT, $wordCount, $readingTime);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @var bool $main
|
||||
* @var ArticlePage $article
|
||||
*/
|
||||
?>
|
||||
|
||||
<article>
|
||||
<?php if ($main): ?>
|
||||
<h2><a href="<?= $article->url() ?>"><?= $article->title() ?></a></h2>
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* @var Kirby\Cms\Site $site
|
||||
* @var Kirby\Cms\Page $page
|
||||
* @var string $slot
|
||||
*/
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* @var Kirby\Cms\Page $page
|
||||
*/
|
||||
?>
|
||||
|
||||
<?php snippet('layout', slots: true) ?>
|
||||
<?php slot() ?>
|
||||
<h1><?= $page->title() ?></h1>
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* @var Kirby\Cms\Page $page
|
||||
*/
|
||||
?>
|
||||
|
||||
<?php snippet('layout', slots: true) ?>
|
||||
<?php slot() ?>
|
||||
<h1><?= $page->title() ?></h1>
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @var Kirby\Cms\Page $page
|
||||
* @var Kirby\Cms\Pages $articles
|
||||
*/
|
||||
?>
|
||||
|
||||
<?php snippet('layout', slots: true) ?>
|
||||
<?php slot() ?>
|
||||
<h1><?= $page->title() ?></h1>
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* @var Kirby\Cms\Kirby $kirby
|
||||
* @var Kirby\Cms\Site $site
|
||||
* @var Kirby\Cms\Page $page
|
||||
*/
|
||||
|
||||
$kirby->response()->type('application/rss+xml');
|
||||
|
||||
|
@ -45,6 +50,7 @@ $writer->writeElement('link', url());
|
|||
$writer->endElement(); // image
|
||||
|
||||
foreach ($articles as $article) {
|
||||
/** @var Kirby\Cms\Page $article */
|
||||
$writer->startElement('item');
|
||||
|
||||
$writer->writeElement('title', $article->title()->toString());
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* @var Kirby\Cms\Page $page
|
||||
*/
|
||||
?>
|
||||
|
||||
<?php snippet('layout', slots: true) ?>
|
||||
<?php slot() ?>
|
||||
<h1><?= $page->title() ?></h1>
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @var Kirby\Cms\Site $site
|
||||
* @var Kirby\Cms\Page $page
|
||||
*/
|
||||
?>
|
||||
|
||||
<?php snippet('layout', slots: true) ?>
|
||||
<?php slot() ?>
|
||||
<header>
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @var Kirby\Cms\Page $page
|
||||
* @var Kirby\Cms\Pages $quotes
|
||||
*/
|
||||
?>
|
||||
|
||||
<?php snippet('layout', slots: true) ?>
|
||||
<?php slot() ?>
|
||||
<h1><?= $page->title() ?></h1>
|
||||
|
|
Loading…
Add table
Reference in a new issue