Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
gatsby-remark-prismjs-copy-button
Advanced tools
Gatsby plugin to add copy button to Remark code block
Add copy button to your prismjs' code blocks.
https://thundermiracle.com/blog/en/2022-03-13-gatsby-add-copy-button-to-code-block/
npm install --save gatsby-transformer-remark gatsby-remark-prismjs gatsby-remark-prismjs-copy-button
Add it to gatsby-config.js
:
※ NOTE: You MUST add gatsby-remark-prismjs-copy-button
before gatsby-remark-prismjs
, as gatsby-remark-prismjs
will transform Code MarkdownASTs to HTML. So gatsby-remark-prismjs-copy-button
will unable to find the Code MarkdownASTs to add copy button.
module.exports = {
plugins: [
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
`gatsby-remark-prismjs-copy-button`,
`gatsby-remark-prismjs`,
],
},
},
],
};
In your template.js.
export const query = graphql`
query ($slug: String!) {
markdownRemark(fields: { slug: { eq: $slug } }) {
html
}
}
`;
export default function Template({ data }) {
return (
<div dangerouslySetInnerHTML={{ __html: data.markdownRemark.html }} />
);
}
Overwrite the style of the copy button.
You can overwrite the style of the copy button by adding the following class to your own style.css
.
.gatsby-remark-prismjs-copy-button-container {
left: 0;
padding-right: 8px;
}
If you have unanswered questions, would like help with enhancing or debugging the plugin, it is nice to include instructions for people who want to contribute to your plugin.
This project is licensed under the terms of the MIT license.
FAQs
Gatsby plugin to add copy button to Remark code block
We found that gatsby-remark-prismjs-copy-button 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.