Search code examples
angularjsnode.jsghost-blog

ghost blog post on website home page


I am using ghost blog integrated with my website as www.domainXX.com/blog.

I want to display few important/recent blog on my website's home page.Is there any way I can do that except writing short description code of your blog manually and then give link to your blog using html/css.

I checked this website "https://www.nerdwallet.com/" and they are using the same concept under "must reads by our expert" section.

Thanks.


Solution

  • Yes, you can do that with Ghost API. You can write a JavaScript widget that fetches your recent posts with ajax.

    $.get(
        ghost.url.api('posts', {
          limit: 2, 
          include: 'count.posts', 
          order: 'count.posts DESC'
        })
      ).done(function (data) {
        console.log('Success!', data);
      });
    

    http://themes.ghost.org/docs/ghost-api-ajax

    FYI ghost.url.api() might not be on your home website so you need reference it from your blog https://www.nerdwallet.com/blog/shared/ghost-url.min.js

    Alternative solution would be to generate embedded RSS widget pointed to your blog. https://feed.mikle.com/