项目作者: TommasoAmici

项目描述 :
Gatsby source plugin for pulling game collections from BoardGameGeek
高级语言: TypeScript
项目地址: git://github.com/TommasoAmici/gatsby-source-bgg.git
创建时间: 2021-05-20T16:44:37Z
项目社区:https://github.com/TommasoAmici/gatsby-source-bgg

开源协议:MIT License

下载



Gatsby
+
BoardGameGeek

gatsby-source-bgg

Source plugin for pulling game collections from BoardGameGeek into Gatsby.
It creates links between entry types and assets (e.g. cover images) so they can be queried in Gatsby using GraphQL.

At a glance

Node.js CI Minzipped bundle size npm version

Getting started

First, install the package

  1. # npm install gatsby-source-bgg
  2. yarn add gatsby-source-bgg

Then, in your gatsby-config.js add the plugin and configure it with all the filters and options you like.
The only required field is username. Here you can find a complete list of options.

The options are a 1:1 mapping of the API options you can find on BoardGameGeek’s documentation.

  1. module.exports = {
  2. plugins: [
  3. {
  4. resolve: "gatsby-source-bgg",
  5. options: {
  6. username: "tommasoamici",
  7. own: 1,
  8. },
  9. },
  10. ],
  11. };

You will then be able to query the games as usual with GraphQL queries, e.g.

  1. query GamesList {
  2. games: allBggGame {
  3. edges {
  4. node {
  5. name
  6. numPlays
  7. coverImage {
  8. childImageSharp {
  9. gatsbyImageData(height: 256, width: 256, formats: [AUTO, WEBP])
  10. }
  11. }
  12. }
  13. }
  14. }
  15. }

Example output:

  1. {
  2. "data": {
  3. "games": {
  4. "edges": [
  5. {
  6. "node": {
  7. "name": "7 Wonders Duel",
  8. "numPlays": 5,
  9. "coverImage": {
  10. "childImageSharp": {
  11. "gatsbyImageData": {
  12. "layout": "constrained",
  13. "backgroundColor": "#282828",
  14. "images": {
  15. "fallback": {
  16. "src": "/static/283f546e590850a05dfea6196db90991/68974/pic3376065.jpg",
  17. "srcSet": "/static/283f546e590850a05dfea6196db90991/d4a57/pic3376065.jpg 64w,\n/static/283f546e590850a05dfea6196db90991/19e71/pic3376065.jpg 128w,\n/static/283f546e590850a05dfea6196db90991/68974/pic3376065.jpg 256w,\n/static/283f546e590850a05dfea6196db90991/3c367/pic3376065.jpg 512w",
  18. "sizes": "(min-width: 256px) 256px, 100vw"
  19. },
  20. "sources": [
  21. {
  22. "srcSet": "/static/283f546e590850a05dfea6196db90991/8257c/pic3376065.webp 64w,\n/static/283f546e590850a05dfea6196db90991/6766a/pic3376065.webp 128w,\n/static/283f546e590850a05dfea6196db90991/22bfc/pic3376065.webp 256w,\n/static/283f546e590850a05dfea6196db90991/d689f/pic3376065.webp 512w",
  23. "type": "image/webp",
  24. "sizes": "(min-width: 256px) 256px, 100vw"
  25. }
  26. ]
  27. },
  28. "width": 256,
  29. "height": 256
  30. }
  31. }
  32. }
  33. }
  34. }
  35. ]
  36. }
  37. },
  38. "extensions": {}
  39. }

Found a bug?

Please file a report in this repository’s issues

Development

If you want to contribute to this project, that’s great to hear!

You can start at CONTRIBUTING.md.