Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
gatsby-transformer-yaml-fulls
Advanced tools
Readme
This it's a fork of gatsby-transformer-yaml-full
YAML parser with support for custom tags and multiple document sources.
npm install gatsby-transformer-yaml-full
Note:
gatsby-transformer-yaml-full
requires a source plugin.
/* gatsby-config.js */
module.exports = {
plugins: [
'gatsby-transformer-yaml-full',
{
resolve: 'gatsby-source-filesystem',
options: {
// 'name' allows users to specify a custom name for the data set.
// In this case, 'cars' becomes the name of the created data set.
name: 'cars',
// 'path' specifies the location of the data files.
path: path.join(__dirname, 'content', 'cars',),
}
}
]
}
You can organize your data as multiple documents, with all documents inside a single file, or as single documents, with a single document per file:
Convert each document inside a file into a node. The node type is based on the file name.
The ./collection.yaml
file below:
---
character: a
number: 1
---
character: b
number: 2
Will return:
{
data: {
allCollectionYaml: {
nodes: [
{
character: 'a',
number: 1
},
{
character: 'b',
number: 2
}
]
}
}
}
With the following query:
query {
allCollectionYaml {
nodes
character
number
}
}
}
Convert each file inside a directory into a node. The node type is based on the directory name.
The following directory structure:
posts/
blog-post.yaml
hello-world.yaml
With ./posts/blog-post.yaml
and ./posts/hello-world.yaml
files,
respectively:
title: Blog post
title: Hello, world!
Will return:
{
data: {
allCollectionYaml: {
nodes: [
{
title: 'Blog post'
},
{
title: 'Hello, world!'
}
]
}
}
}
With the following query:
query {
allPostsYaml {
nodes
title
}
}
}
With plugins, specific YAML tags can be enabled and processed.
With gatsby-yaml-full-markdown
plugin activated:
/* gatsby-config.js */
module.exports = {
plugins: [
{
resolve: 'gatsby-transformer-yaml-full',
options: {
plugins: ['gatsby-yaml-full-markdown']
}
}
// ...
]
}
Using a !markdown
tag:
title: Blog post
content: !markdown |
## Heading
Article content.
Will return:
{
title: 'Blog post',
content: '<h2>Heading</h2>\n<p>Article content.</p>\n'
}
Type: Array
. Default: []
.
Enable custom YAML tags (e.g. gatsby-yaml-full-import
,
gatsby-yaml-full-markdown
, etc.).
id
and yamlId
To keep consistency with the official gatsby-transformer-yaml
plugin, if a
YAML file contains an id
field, it'll be renamed to yamlId
— id
is a
reserved key in Gatsby.
The plugin should return a function, which should return an object with the following properties:
!import
, !markdown
)The first argument of the function will be the helpers
object received from
Gatsby on exports.onCreateNode
. The second will be the plugin options object
set in gatsby-config.js
.
// index.js
module.exports = function ({ node }, pluginOptions) {
return {
tag: '!example',
options: {
kind: 'scalar',
construct: () => `Parent directory is ${node.dir}`,
},
}
}
More information about creating local plugins, specific to your project, can be found on Gatsby documentation.
FAQs
YAML parser with support for custom tags and multiple document sources
The npm package gatsby-transformer-yaml-fulls receives a total of 1 weekly downloads. As such, gatsby-transformer-yaml-fulls popularity was classified as not popular.
We found that gatsby-transformer-yaml-fulls demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.