icon
React js
arrow rightGetting Started
Install library
arrow rightAPI list
Get all posts
Get post by id
Get featured posts
Get related posts
Get posts by category
Get posts by tags
Get posts by author
Get all categories
Get all tags
Get all authors
arrow rightStyles
Add primary color
Getting started with Upnread
Upnread is a CMS that help companies and users to build custom blogs. You need install @upnread/post-renderer library to render your posts that you have created on your account. You don't have an account yet? click here to register
Install Upnread post renderer library
The first step is installing the Upnread post renderer library to render any post you have already created on your Upnread account.
npm install @upnread/post-renderer
Or
yarn add @upnread/post-renderer
Implementation example
Every single response of any of the end-points list that we have, have the prop body, the prop body contain the post that you already created. We are going to use this library to render the post body.
import React from 'react'
import PostRenderer, { getPost } from '@upnread/post-renderer'

async function fetchSinglePost() {
  const response = await getPost({
    slug: 'introducing-upnread', // post slug
    token: 'your secret token' // secret token
  })

  return response
}

const App = () => {
  const [post, setPost] = React.useState({
    body: '',
    blog: { primary_color: '' }
  })

  React.useEffect(() => {
    async function fetchPost() {
      const { data } = await fetchSinglePost()
      setPost(data)
    }

    fetchPost()
  }, [])

  return (
    <PostRenderer primaryColor={post.blog.primary_color} post={post.body} />
  )
}

export default App