Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
gatsby-transformer-javascript-frontmatter
Advanced tools
Gatsby transformer plugin for JavaScript to extract exports.frontmatter statically.
Parses JavaScript files to extract frontmatter from exports.
npm install --save gatsby-source-filesystem gatsby-transformer-javascript-frontmatter
To use this plugin you also need gatsby-source-filesystem installed and configured.
// In your gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-source-filesystem`,
options: {
name: `pages`,
path: `${__dirname}/src/pages/`,
},
},
"gatsby-transformer-javascript-frontmatter",
],
}
This plugin uses @babel/parser and @babel/traverse to statically read the frontmatter exports.
In a .js
file, export a frontmatter object to set your metadata variables, like so:
import React from "react"
exports.frontmatter = {
title: "Choropleth on d3v4",
written: "2017-05-04",
layoutType: "post",
path: "choropleth-on-d3v4",
category: "data science",
description: "Things about the choropleth.",
}
export default MyComponent
You can also use a named export for the frontmatter object:
export const frontmatter = {
title: "Choropleth on d3v4",
written: "2017-05-04",
layoutType: "post",
path: "choropleth-on-d3v4",
category: "data science",
description: "Things about the choropleth.",
}
You'd be able to query your frontmatter like:
{
allJavascriptFrontmatter {
edges {
node {
frontmatter {
error
path
title
written
category
description
updated
}
}
}
}
}
Which would return something like:
{
"data": {
"allJavascriptFrontmatter": {
"edges": [
{
"node": {
"frontmatter": {
"error": false,
"path": "choropleth-on-d3v4",
"title": "Choropleth on d3v4",
"written": "2017-05-04",
"category": "data science",
"description": "Things about the choropleth.",
"updated": null
}
}
}
]
}
}
}
Any attribute on "frontmatter" across your js files will be exported. If a file is missing it, the value will be null.
The error
field will contain false
or an object with error information just to
give a surface level view of what the query is pulling out.
{
"error": {
"err": true,
"message": "we threw an error",
"stack": "This is a stringified stack trace"
}
}
FAQs
Gatsby transformer plugin for JavaScript to extract exports.frontmatter statically.
The npm package gatsby-transformer-javascript-frontmatter receives a total of 771 weekly downloads. As such, gatsby-transformer-javascript-frontmatter popularity was classified as not popular.
We found that gatsby-transformer-javascript-frontmatter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.