GithubHelp home page GithubHelp logo

raygervais / gatsby-source-unsplash Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vacas5/gatsby-source-unsplash

0.0 2.0 0.0 10 KB

Source plugin for Gatsby to pull in unsplash photos from a collection

License: MIT License

JavaScript 100.00%

gatsby-source-unsplash's Introduction

gatsby-source-unsplash

Source plugin for pulling photo data by collection into Gatsby from the official Unsplash API.

Install

npm install --save gatsby-source-unsplash

How to use

Before using the Unsplash API, you need to register as a developer and read the API Guidelines.

Note: Every application must abide by the API Guidelines. Specifically, remember to hotlink images, attribute photographers, and trigger a download when appropriate.

// In your gatsby-config.js
// Application id provided by Unsplash
// Collections must be public to return photos
plugins: [
  {
    resolve: `gatsby-source-unsplash`,
    options: {
      appId: `12345678`,
      collections: [
        `098765`
      ],
      // optional: will only get page 1, so increase this count to include > 10 photos
      perPage: `100`
    },
  },
];

How to query

Get all photo urls in reverse chronological order with the photographer's name:

query PhotosQuery {
    allUnsplashPhoto(sort: { fields: [created_at], order: DESC }) {
      edges {
        node {
          id
          user {
            id
            name
          }
          urls {
            full
            regular
            small
          }
          description
          created_at
        }
      }
    }
}

Get a specific photo's urls by id with links to photographer's Unsplash profile:

query PhotoQuery {
    unsplashPhoto(id: { eq: "GnY_mW1Q6Xc" }) {
        id
        description
        urls {
            full
            regular
            small
        }
        user {
            name
            links {
                html
            }
        }
    }
}

gatsby-source-unsplash's People

Contributors

dependabot[bot] avatar lukechesser avatar vacas5 avatar yavorpunchev avatar

Watchers

 avatar  avatar

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.