
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
@bcgov/gatsby-source-github-raw
Advanced tools
Leverages the Github Contents API to convert files into transformable Gatsby Nodes
This project is moving to
@bcgov/gatsby-source-github-raw
repo;
A simplified way of leveraging the Github Contents Api
as Gatsby graphql nodes.
npm install --save @bcgov/gatsby-source-github-raw
{
resolve: '@bcgov/gatsby-source-github-raw',
options: {
githubAccessToken: '...',
files: [
'https://github.com/foo/bar/blob/master/something.md'
]
}
}
There are a few ways to pass in files
['https://github.com/foo/bar/blob/master/something.md', 'https://github.com/foo/bar/blob/master/something2.md']
if you are binding properties, you need to ensure that the properties that you bind between files match the same schema since this process depends on gatsby's graphql type inferrence routine
[
{
url: 'https://github.com/foo/bar/blob/master/something.md'
labels: [ // labels will become a bound property that is available at node._xxboundProperties.labels
'cool',
'featured',
]
},
{
url: 'https://github.com/foo/bar/blob/master/something2.md',
labels: [ // labels will become a bound property that is available at node._xxboundProperties.labels
'featured',
]
}
]
gatsby-config.js
file is cumbersome.
You may store your 'files config' into a json file and have gatsby-transformer-json
pick it up.
The implied nodeType
that is created from the directory can be passed in as the files
optionfoo.json
[
{
"url": "https://github.com/foo/bar/blob/master/something.md",
"labels": [
"cool",
"featured"
]
},
{
"url": "https://github.com/foo/bar/blob/master/something2.md",
"labels": [
"featured"
]
}
]
gatbsy-config
{
resolve: '@bcgov/gatsby-source-github-raw',
options: {
githubAccessToken: '...',
files: 'fooJson'
}
}
/**
* fileCallback
* @param {Function} getNodes gatsby getNodes function in case you need it
* @returns {Array<String> | Array<Object>} a list of files in strings or objects
**/
const fileCallback = getNodes => {
// get nodes allows you to produce a set of urls based on your own conditions, for example if you
// had multiple json files that held url information that you wanted to normalize and use
return ['...list of files']
}
{
resolve: '@bcgov/gatsby-source-github-raw',
options: {
githubAccessToken: '...',
files: () => ['https://github.com/foo/bar/blob/master/blah.md']
}
}
Because manifests can be passed in as plain js objects as well as loaded through the use of
@bcgov/gatsby-transformer-json
, to maintain consistency between these two possible sources, the following
properties are not usable within json
files that are leveraged as a source for files.
This is because these properties are default properties applied to any graphql node within gatsby.
Bound Properties are accessed at node._xxboundProperties
FAQs
Leverages the Github Contents API to convert files into transformable Gatsby Nodes
The npm package @bcgov/gatsby-source-github-raw receives a total of 2 weekly downloads. As such, @bcgov/gatsby-source-github-raw popularity was classified as not popular.
We found that @bcgov/gatsby-source-github-raw demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.