
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
gatsby-plugin-slug
Advanced tools
By default gatsby generate url by following directories structure.
For example, the following directory structure generate path url mysite.com/2018/08/my-first-post
2018
↳ 08
↳ my-first-post
With the same directory structure using gatsby-plugin-slug
, you can add a custom slug field to remark nodes to have custom urls like mysite.com/super-post
You can download gatsby-plugin-slug
from the NPM registry via the
npm
or yarn
commands
yarn add gatsby-plugin-slug
npm install gatsby-plugin-slug --save
gatsby-config.js
file:module.exports = {
plugins: ["gatsby-plugin-slug"],
}
slug
field in the frontmatter of your markdown files:---
slug: my-custom-slug
---
slug
field for the path
key when you create a new page in you gatsby-node.js
:const postTemplate = path.resolve("./src/templates/post.js")
exports.createPages = ({graphql, boundActionCreators}) => {
const {createPage} = boundActionCreators
return new Promise((resolve, reject) => {
resolve(
graphql(
`
{
posts: allMarkdownRemark() {
edges {
node {
fields {
slug
}
}
}
}
}
`
).then(result => {
const posts = result.data.posts.edges
posts.forEach(post => {
createPage({
path: post.node.fields.slug,
component: blogPostTemplate,
context: {
slug: post.node.fields.slug,
},
})
})
})
)
})
}
slug
in the context to get more data:import React from "react"
const PostTemplate = ({data: {post}}) => (
<div>
<h1>{post.title}</h1>
<div dangerouslySetInnerHTML={{__html: post.html}} />
</div>
)
export default PostTemplate
export const pageQuery = graphql`
query PostBySlug($slug: String!) {
post: markdownRemark(fields: {slug: {eq: $slug}}) {
html
frontmatter {
title
}
}
}
`
See CONTRIBUTING.md guidelines
See CHANGELOG.md
This project is licensed under the MIT License - see the LICENCE.md file for details
FAQs
Add slug field to MarkdownRemark and Mdx nodes
The npm package gatsby-plugin-slug receives a total of 237 weekly downloads. As such, gatsby-plugin-slug popularity was classified as not popular.
We found that gatsby-plugin-slug demonstrated a not healthy version release cadence and project activity because the last version was released 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.