getSnippet() public method

Get a preview snippet of a blog post
public getSnippet ( array $post, boolean $after = false ) : array
$post array Post data
$after boolean Do we want the content after the fold?
return array
Esempio n. 1
0
 /**
  * The homepage for an Airship.
  *
  * @route /
  */
 public function index()
 {
     $this->blog = $this->blueprint('Blog');
     if (!\file_exists(ROOT . '/public/robots.txt')) {
         // Default robots.txt
         \file_put_contents(ROOT . '/public/robots.txt', "User-agent: *\nAllow: /");
     }
     $blogRoll = $this->blog->recentFullPosts((int) ($this->config('homepage.blog-posts') ?? 5));
     $mathJAX = false;
     foreach ($blogRoll as $i => $blog) {
         $blogRoll[$i] = $this->blog->getSnippet($blog);
         if (Binary::safeStrlen($blogRoll[$i]['snippet']) !== Binary::safeStrlen($blog['body'])) {
             $blogRoll[$i]['snippet'] = \rtrim($blogRoll[$i]['snippet'], "\n");
         }
         $mathJAX |= \strpos($blog['body'], '$$') !== false;
     }
     $args = ['blogposts' => $blogRoll];
     $this->config('blog.cachelists') ? $this->stasis('index', $args) : $this->lens('index', $args);
 }
Esempio n. 2
0
 /**
  * Blog post home
  *
  * @route /
  */
 public function index()
 {
     $blogRoll = $this->blog->recentFullPosts((int) $this->config('homepage.blog-posts') ?? 5);
     $mathJAX = false;
     foreach ($blogRoll as $i => $blog) {
         $blogRoll[$i] = $this->blog->getSnippet($blog);
         if (Binary::safeStrlen($blogRoll[$i]['snippet']) !== Binary::safeStrlen($blog['body'])) {
             $blogRoll[$i]['snippet'] = \rtrim($blogRoll[$i]['snippet'], "\n");
         }
         $mathJAX = $mathJAX || \strpos($blog['body'], '$$') !== false;
     }
     $args = ['pageTitle' => \__('Blog'), 'blogroll' => $blogRoll, 'mathjax' => $mathJAX];
     $this->config('blog.cachelists') ? $this->stasis('blog/index', $args) : $this->lens('blog/index', $args);
 }