July 11, 2020
yarn add gatsby-remark-code-buttons
You might be better to put "gatsby-remark-code-buttons" before "gatsby-remark-prismjs". In my case, when I put "gatsby-remark-code-buttons" after "gatsby-remark-prismjs", it did not work for some reasons. I am not sure why it was happened.
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: "gatsby-remark-code-buttons",
options: {
tooltipText: `Copy to clipboard`,
toasterText: "Copied to clipboard",
toasterDuration: 5000,
},
},
// other plugins here
]
}
}
I created remark-copy.css under "./src/styles/". But you can put the file anywhere you want.
.gatsby-code-button-container {
touch-action: none;
display: flex;
justify-content: flex-end;
position: relative;
top: 28px;
right: 3px;
z-index: 100;
pointer-events: none;
}
.gatsby-code-button-icon {
display: block;
width: 14px;
height: 14px;
fill: gray;
}
You need to add the below to gatsby-browser.js
import "./src/styles/remark-copy.css";
Written by Yasuhiro Ito
Software engineer