stldo / gatsby-transformer-yaml-full Goto Github PK
View Code? Open in Web Editor NEWYAML parser with support for custom tags and multiple document sources
License: MIT License
YAML parser with support for custom tags and multiple document sources
License: MIT License
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
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.
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
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)
Following the docs https://github.com/stldo/gatsby-transformer-yaml-full/tree/master/packages/gatsby-transformer-yaml-full#single-document I run into an odd behavior.
I've created 2 yaml files within a folder
Using 0.2.0 I got what's expected
0.3.0 & 0.3.1 only returns only one node (as I experienced usually the last modified file)
Thanks for your help in advance!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.