Coder Social home page Coder Social logo

molebox / gatsby-theme-pocket Goto Github PK

View Code? Open in Web Editor NEW
40.0 2.0 11.0 3.09 MB

A Gatsby theme that adds a pocket to your website.

Home Page: gatsby-theme-pocket.vercel.app

JavaScript 100.00%
gatsby gatsby-theme gatsby-plugin pocket mobile-integration react

gatsby-theme-pocket's Introduction

gatsby-theme-pocket

A Gatsby theme that adds your saved pocket articles to your gatsby site with inbuilt SEO.

The idea behind this theme is to add a curated list of articles of interest to your website. These can be for your personal site where you want to keep a list of articles you read, your business site where you want to show your visitors articles that relate to your market or just a place to save stuff that interests you from the internet. You need to have the pocket app installed on your mobile or the browser extension, it is from there that you save your articles.

The articles are filtered by tag so when you save an article in your app or browser you should tag them so that they are categorized and easier for people to view.

Example live site - gatsby-theme-pocket-example.netlify.com

v.0.3.0 Changes

Added the ability to use a custom url instead of /articleIndex. A new theme option called customUrl enables you to set your own url for the theme page.

Example:

module.exports = {
    plugins: [
        {
            resolve: 'gatsby-theme-pocket',
            options: {
                ...otherProps
                customUrl: 'research'
            }
        }
    ]
}

Setup

Authorize your pocket account

Run yarn add gatsby-theme-pocket You will first need to authorize your pocket credentials. Run yarn pocket-setup from the command line. Open the browser at the given url and authorize your account. You will then be given an access-token unique to your account. Save this as you will need to pass this to the gatsby-theme-pocket in the next step.

Props

The theme supports the following props:

Name Optional Type Default
pocketAccessToken No string None
weeksOfHistory No number None
tagFilter No boolean None
tagFilterString Yes string 'untagged'
searchFilter No boolean None
searchFilterString Yes string 'Web Dev'
pageTitle No string None
pageDescription No string None
seoTitle No string None
seoDescription No string None
seoKeywords No string[] None
siteUrl No string None
customUrl Yes string None

Props Descriptions

  • weeksOfHistory: Number of weeks worth of articles to fetch
  • tagFilter:
    • true will use the tagFilterString value to get articles with that tag.
    • false will ignore the tagFilterString value
  • tagFilterString: If tagFilter is true then get articles tagged with this value. '\_untagged\_' will only return articles with no tags. It will default to '\_untagged\_'.
  • searchFilter:
    • true will use the searchFilterString value to get articles with that value in the URL or title.
    • false will ignore the searchFilterString value
  • searchFilterString: If searchFilter is true then get articles with this value in the URL or title.
  • pageTitle: The h1 title of the articles page
  • pageDescription: The h2 dexcription of the articles page
  • seoTitle: SEO title of the page
  • seoDescription: SEO description of the page
  • seoKeywords: SEO keywords as a string array
  • siteUrl: Your site URL for SEO
  • customUrl: A custom URL to be used instead of the default /articleIndex

Setup theme

Once you have the theme installed and your access-token add the theme to your gatsby-config.js

module.exports = {
    plugins: [
        {
            resolve: 'gatsby-theme-pocket',
            options: {
                pocketAccessToken: MY_ACCESS_TOKEN,
                weeksOfHistory: 52,
                tagFilter: false,
                searchFilter: false,
                pageTitle: 'Articles of interest',
                pageDescription: 'This is a curated list of articles tagged under different areas of interest.',
                seoTitle: 'gatsby-theme-pocket',
                seoDescription: 'A Gatsby theme that adds your pocket app articles to your gatsby website',
                seoKeywords: ['gatsby', 'react', 'pocket', 'gatsby-theme', 'gatsby-plugin', 'articles'],
                siteUrl: 'https://www.hungrybearstudio.com/'
            }
        }
    ]
}

The theme ships as a page you can navigate to my-website/articleIndex This page will give you centered list of cards with the articles title, excerpt, image if there is on and word count of the article. Each card is an anchor tag so the user can click the card to be taken to the article.

The Article component (card) is a separate component which can be shadowed and altered if you desire.

The theme uses theme-ui out of the box so if you wish to edit the colors or fonts used you can shadow the theme-ui index of this theme and change them. The Article component uses the sx prop to style its elements meaning you can make the changes in your theme-ui file and they will update the component.

TODO:

  • Update readME to include full examples and descriptions of what can be done.
  • Add more options to the theme-ui context which will enable easier editing of the components.
  • Add different layout defaults - currently a center flexbox layout. Perhaps add a grid option
  • Add favorites
  • Add tags to articles - Done
  • Add search functionality

Built With

Authors

  • Rich Haines - Hungry Bear Studio

License

This project is licensed under the MIT License

gatsby-theme-pocket's People

Contributors

dependabot[bot] avatar molebox avatar smai-f avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gatsby-theme-pocket's Issues

Deleted articles render as empty articles

After deleting articles from one's Pocket dashboard, they are still returned as part of the response from the Pocket API with a bunch of null fields, and then they render like so:

image

Would be great to exclude these. Again, happy to contribute if you're open to it!

GraphQL query breaks when no articles have an image or any tags

Hey @molebox ! This is an awesome theme, thanks for writing it.

I ran into a couple issues as I got this setup locally.

  1. I couldn't run the yarn pocket-setup script on my Mac at first due to the binary being DOS-based -- I had to delete the file and re-create to fix. It manifests with this error: env: node\r: No such file or directory. Not a big deal but I'm guessing it would scare some people off from using it.

  2. The bigger issue -- if none of my saved Pocket articles have an image or any tags, the GraphQL query in Articles.js breaks:

 ERROR #85923  GRAPHQL

There was an error in your GraphQL query:

Cannot query field "image" on type "PocketArticle".

If you don't expect "image" to exist on the type "PocketArticle" it is most likely a typo.
However, if you expect "image" to exist there are a couple of solutions to common problems:

- If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server
- The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have
- You want to optionally use your field "image" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add at least one entry with that field ("dummy content")

It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "PocketArticle":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions

File: node_modules/gatsby-theme-pocket/src/components/Articles.js:99:11

I don't have a ton of GraphQL experience but confident I can figure it out. I'm presuming that if there aren't any tags on any articles, the best UI would be to not render the "Filter by tags..." dropdown. Would you agree?
Would you accept a contribution for these fixes?

Thanks and cheers!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.