How to use @tryghost/content-api - 5 common examples

To help you get started, we’ve selected a few @tryghost/content-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / tryghost__content-api / tryghost__content-api-tests.ts View on Github external
import GhostContentAPI, { PostOrPage } from '@tryghost/content-api';

const api = GhostContentAPI({ url: 'test', version: 'v3', key: '' }); // $ExpectType GhostAPI

let pages: PostOrPage[];
const pagesBrowsePromise = api.pages.browse(); // $ExpectType Promise

pagesBrowsePromise.then(pageObject => {
    pages = pageObject.pages;

    api.pages.read(pages[0], { include: 'authors' }); // $ExpectType Promise
});
github brianlovin / brian-lovin-next / src / data / ghost.ts View on Github external
import GhostContentAPI from "@tryghost/content-api";

// Create API instance with site credentials
const api = new GhostContentAPI({
  url: 'https://overthought.ghost.io',
  key: 'a731438732f44c2cdf30dd4955',
  version: "v3"
});

export async function getPosts() {
  return await api.posts
    .browse({
      limit: "all"
    })
    .catch(err => {
      console.error(err);
    });
}

function isFeatured(post) {
github tadoku / web / src / app / blog / api.ts View on Github external
import GhostContentAPI from '@tryghost/content-api'
import { Post } from './domain'

const api = GhostContentAPI({
  url: process.env.GHOST_URL || '',
  key: process.env.GHOST_KEY || '',
  version: 'canary',
})

const getPosts = async (): Promise => {
  const response = await api.posts.browse({
    limit: 5,
    include: ['authors', 'tags'],
    formats: ['html'],
  })

  if (!response) {
    return []
  }
github electronthemes / ghost-finder / src / ghost-finder.js View on Github external
this.resultTemplate = resultTemplate
        this.singleResultTemplate = singleResultTemplate
        this.showResult = document.querySelector(showResult)

        this.excerpt_length = excerpt_length
        this.time_format = time_format

        /**
         * trigger when user type to search
         */
        this.input.addEventListener('keyup', this.doSearch)

        /**
         * Initialize ghost content api constructor
         */
        this.api = new GhostContentAPI({
            url: this.homeUrl,
            key: this.contentApiKey,
            version: 'v3',
        })
    }

@tryghost/content-api

JavaScript Client Library for the Ghost [Content API](https://ghost.org/docs/content-api/)

MIT
Latest version published 7 months ago

Package Health Score

62 / 100
Full package analysis

Popular @tryghost/content-api functions

Similar packages