1.0.8 • Published 3 years ago

@upnread/post-renderer v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

logo

@upnread/post-renderer

You can use this library in any of your React projects.

Upnread is a CMS that help companies and users to build custom blogs! You can install @upnread/post-renderer library to render your amazing posts that you have created on your account.

NPM JavaScript Style Guide

Note

Before installing this library make sure that you have created an account in Upnread

Install

npm install --save @upnread/post-renderer

Read our documentation!

Enter to our documentation, we have a list of end points you can use to get your posts and build your custom blog.


Params

Paramrequiredvalue
postyesYou need to the send post.body prop
primary_colorNoYou can send post.blog.primary_color prop or just send any primary color HEX code

You can request your post by id or by slug

Example of usage

import React from 'react'
import PostRenderer, { getPost } from '@upnread/post-renderer'

async function fetchSinglePost() {
  const response = await getPost({
    slug: 'Your post slug',
    token: 'Your 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

Visit our web site

https://upnread.com