Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arjunrao87/gatsby-source-reddit
Gatsby source plugin that makes calls to the Reddit API
https://github.com/arjunrao87/gatsby-source-reddit
Last synced: 7 days ago
JSON representation
Gatsby source plugin that makes calls to the Reddit API
- Host: GitHub
- URL: https://github.com/arjunrao87/gatsby-source-reddit
- Owner: arjunrao87
- Created: 2018-07-10T12:12:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-28T00:54:49.000Z (about 6 years ago)
- Last Synced: 2024-10-18T17:09:49.637Z (about 1 month ago)
- Language: JavaScript
- Size: 29.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gatsby-source-reddit ![npm](https://img.shields.io/npm/v/gatsby-source-reddit.svg) ![npm](https://img.shields.io/npm/dt/gatsby-source-reddit.svg)
Source plugin for pulling data into Gatsby from [Reddit API](https://www.graphqlhub.com/playground/reddit)
# Usage
## NPM
Package available [here](https://www.npmjs.com/package/gatsby-source-reddit)
## Available parameters
- username : user for who you want to query data
- subredditName : subreddit for which you want to query dataIf neither is provided, then an empty node with a random ID is passed back
## gatsby-config.js
```javascript
// In your gatsby-config.js
plugins: [
{
resolve: `gatsby-source-reddit`,
options: {
username:`gallowboob`
}
},
]
```or
```javascript
plugins: [
{
resolve: `gatsby-source-reddit`,
options: {
subreddit:`pics`
}
},
]
```# GraphQL queries
```
fragment UserDetails on RedditUser {
fullnameId
username
created
createdISO
linkKarma
commentKarma
}fragment CommentDetails on RedditComment {
author {
...UserDetails
}
body
}query user {
reddit {
user(username: "aristotle") {
...UserDetails
}
}
}query subreddit {
reddit {
subreddit(name: "dataisbeautiful") {
name
fullnameId
title
publicDescription
accountsActive
subscribers
created
createdISO
hotListings {
title
fullnameId
score
numComments
url
author {
...UserDetails
}
comments {
...CommentDetails
}
}
newListings {
title
fullnameId
score
numComments
url
author {
...UserDetails
}
comments {
...CommentDetails
}
}
risingListings {
title
fullnameId
score
numComments
url
author {
...UserDetails
}
comments {
...CommentDetails
}
}
controversialListings {
title
fullnameId
score
numComments
url
author {
...UserDetails
}
comments {
...CommentDetails
}
}
topListings {
title
fullnameId
score
numComments
url
author {
...UserDetails
}
comments {
...CommentDetails
}
}
}
}
}
```