Excerpt

Adds manual page excerpt feature.

5 stars out of 5

1 0 0 0 0
  • Author Taufik Nurrohman
  • Maintainer 1
  • Member
  • Version 1.1.0

Usage

To manually activate the page excerpt, insert a  or  HTML entity at a specific line where you want to mark the end of the manual page excerpt:

---
title: Page Title
description: Page description.
author: Taufik Nurrohman
type: Markdown
...

This part will be the page excerpt.



Rest of the page content goes here.

To display the manual page excerpt in your layout:

<?php foreach ($pages as $page): ?>
  <article>
    <h3>
      <?= $page->title; ?>
    </h3>
    <?= $page->excerpt; ?>
    <p>
      <a href="<?= eat($page->url . '#next:' . $page->id); ?>">
        <?= i('Read More'); ?>
      </a>
    </p>
  </article>
<?php endforeach; ?>

By default, this extension will not insert HTML markup as a jump target. The excerpt marker will be normalized to the native form feed character in the output. You can add a hook in your layout’s index.php file to convert the character into your desired HTML markup to jump to:

if ($site->is('page')) {
    Hook::set('page.content', function ($content) {
        if (!$content) {
            return $content;
        }
        return strtr($content, ["\f" => '<hr id="next:' . $this->id . '" role="doc-pagebreak">']);
    });
}

0 Comments

No comments yet.