Giter VIP home page Giter VIP logo

gatsby-transformer-yaml-full's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gatsby-transformer-yaml-full's Issues

Syntax Highlighting

Hey! Thanks for the plugin ๐Ÿ‘ it is really very handy to keep markdown in yaml files

The only thing that is missing is syntax highlighting for markdown. Do you have any ideas how to enable it? I usually use VSCode but I'd happy to have a solution in any online/offline editor

Allow plugins to return a list of types

I haven't actually run this plugin yet, but from looking at the code, you assume each plugin returns exactly one type, which seems inconvenient. This way, if you have 100 custom types you'd need to create 100 modules, ie 100 .js files. My own use-case has about 20, so you can see why I want this.

Custom type plugin qraphql error on save YAML file

Hi, I'm having some difficulty creating a custom type plugin.

The goal is to take a youtube videoID fetch the thumbnail url and title using the YouTube API

The plugin works as expected on first pass, however after editing and saving the yaml file I get an error Cannot query field "allVideosYaml" on type "Query". I think it has something to do with gatsby re-rwiting the schema before the construct function has completed.

Am I approaching this in the right way do you think?

// index.js

const YOUTUBE_API_KEY = "abcd"
const fetch = require("node-fetch")

module.exports = () => ({
  tag: "!YouTube",
  options: {
    kind: "scalar",
    construct: async (id) => {
      const response = await fetch(
        `https://www.googleapis.com/youtube/v3/videos?part=snippet&id=${id}&key=${YOUTUBE_API_KEY}`
      )
      const data = await response.json()
      const {
        title,
        thumbnails: {
          medium: { url },
        },
      } = data.items[0].snippet
      return {
        title,
        thumbnail: url,
        id,
      }
    },
  },
})
// videos.yaml
video: !YouTube 5uG7unM1ewE
content: !markdown |
  #some description text

Thanks for taking a quick look if you get a moment.
-Paul

Build error caused by recent commit

I recently upgraded my toolchain and went from gatsby-transformer-yaml-full version 0.4.2 ==> 0.4.5 and experienced the following error message immediately upon attempting to start Gatsby:

$ gatsby develop

 ERROR 

Error in "/projects/app-client/node_modules/gatsby-transformer-yaml-full/gatsby-node.js": Unexpected token '.'

  Error: /projects/app-client/node_modules/gatsby-transformer-yaml-full/gatsby-node.js:80
      } else if (isPlainObject(content) && !content.internal?.type) {
                                                             ^
  SyntaxError: Unexpected token '.'

I suspect there is logical problem here combining the "not" operator with optional chaining that might be remedied by wrapping in parens, i.e. !(content.internal?.type)

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.