2.0.5 • Published 10 months ago

mediumpostscard v2.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

CSR SSR Licence


📝 Table of Contents

About

Are you looking for a React library to display your medium posts that render both the client side and on the server side? So you are in the right place! Medium Posts Card get your medium articles, and displays them on your website through an easy to use component. Just download and use, as simple as that.

Install

Install this library with one of the commands below

yarn add mediumpostscard

//or

npm install mediumpostscard

Components

Carousel

import { Carousel } from 'mediumpostscard'

function Example(){
  return (
    <Carousel username="alex.streza" />
  )
}

export default Example
Prop nameDescriptionTypeDefault
usernaneSets your Medium usernameStringunderfined
dataMediumSet data Medium (only to Server Side Rendering)Objectunderfined
optionsObject with optionsObjectObject
OptionDescriptionTypeDefault
borderRadiusSet if the card will have rounded edgesBooleantrue
openInNewTabSet if the link of article will openned in new tabBooleantrue
showTagsDefine if the card will show article tagsBooleanfalse
showDateSet if the card will show the date of the articleBooleanfalse
ssrSet if the component should rendered on serverBooleanfalse

List

import { List } from 'mediumpostscard'

function Example(){
  return (
    <List username="alex.streza" />
  )
}

export default Example
Prop nameDescriptionTypeDefault
usernaneSets your Medium usernameStringunderfined
dataMediumSet data Medium (only to Server Side Rendering)Objectunderfined
optionsObject with optionsObjectObject
OptionDescriptionTypeDefault
openInNewTabSet if the link of article will openned in new tabBooleantrue
showTagsDefine if the card will show article tagsBooleantrue
showDateSet if the card will show the date of the articleBooleantrue
borderRadiusSet if the card will have rounded edgesBooleanfalse
ssrSet if the component should rendered on serverBooleanfalse

Label

import { Carousel, Label } from 'mediumpostscard'

function Example(){
  return (
    <Label>
      <Carousel username="alex.streza" />
    </Label>
  )
}

export default Example
import { List, Label } from 'mediumpostscard'

function Example(){
  return (
    <Label>
      <List username="alex.streza" />
    </Label>
  )
}

export default Example
Prop nameDescriptionTypeDefault
textSet text on labelString'Medium Articles'
childrenSet component to be labeledJSX.ElementNo default

Server Side Rendering

const dataMedium = fetchMedium('yourmediumusername')

Next define ssr as true, according to the example

<Carousel dataMedium={dataMedium} options={{ssr: true}} />

In the example above, I used the Carousel component, but you do the same with the List component.

Next I will show an example of how to make server side on Next.js

import Head from 'next/head'
import { List, fetchMedium } from 'mediumpostscard'

export default function Home({dataMedium}) {
  return (
    <div>
      <Head>
        <title>Create Next App</title>
        <meta name="description" content="Generated by create next app" />
        <link rel="icon" href="/favicon.ico" />
      </Head>

      <List dataMedium={dataMedium} options={{ssr: true}} />

    </div>
  )
}

export async function getStaticProps() {
  const dataMedium = await fetchMedium('alex.streza')
  return {
    props: {
      dataMedium
    }
  }
}

How to contribute

Fork this repository, make clone for your machine.

Install the dependencies with the command below:

yarn install

To view on storybook

yarn storybook

To build

yarn build

To run the tests.

yarn test

More

Didn't you like any of the components? No problem! You can use Medium Posts API to build your own react component. Moreover you too can contribute with code. Feel free to add new features to our library. We are open-source.

✍️ Author