How to add content from a kirby website on an external website?

Hello everyone,
Is it possible to add content from a kirby website on an external website.

For example:

  • a blog is made with kirby and I would like to display the last 3 articles on an external website (which is installed on the same server by the way). Something like a widget.

Any ideas?
Thank you

Yes, it’s possible. You can use routes to expose the last 3 articles either via JSON or HTML.

Thank you. I am going to check that.

This would be something like that

c::set('routes', array(
  array(
    'pattern' => 'blog/widget',
    'action'  => function() {
      $collection = page('blog')->children()->visible()->limit(3)->toArray();
      return response::json($collection);
    }
  )
));