Prefect: Add "copy" button to code in tutorials

Created on 15 Sep 2018  路  16Comments  路  Source: PrefectHQ/prefect

Hovering over a code block should bring up a "copy" button to easily execute code snippets.

Wouldn't shock me if this ends up in VuePress proper, but maybe we can quickly throw something together. Not pressing.

blocked docs help wanted

Most helpful comment

All 16 comments

As stated in #703, had a need so I packaged it up as a plugin. Fully functional and I am fine offering this to you all as a core plugin.

https://github.com/dovy/plugin-clipboard-copy

Should work out of the box for anyone.

Nice @dovy thanks! I'll take a look at this.

@dovy do you plan to make this npm installable?

Ha, sure. I was planning to see if VuePress wanted to merge this into their core. I'll take a look at getting it installable via npm.

This is so great! Thanks @dovy!

Let me know if you hit any problems. Works pretty solid for me.

Someone correct me if I'm wrong, but I _believe_ plugins aren't supported until vuepress 1.x, so this issue needs #770 to be resolved before I can use it.

For the record, I did include:

plugins: [['@dovyp/plugin-clipboard-copy', true]],

in config.js and

"@dovyp/plugin-clipboard-copy": "^1.0.0-alpha.3",

in package.json but the copy buttons didn't appear.

I鈥檓 using vuepress 1x and I couldn鈥檛 get it to work properly either. It鈥檚 so odd. It works if it鈥檚 in the root directory of my repo and I exclude the @dovyp/ bit from the config.

@cicdw i can take a look into this!

@dovy thank you! Hopefully once we work through the CSS issue in #770 blocking our upgrade, we will be able to include this

Ha, I am still trying to figure out how to make the sidebars be dynamic with the same style you have. I'd love the collapsable sections as your config has. ;)

Thank you! Check our config.js, I think it's just done by nesting sections.

Fixed the issues with the install.

package.json

@dovyp/vuepress-plugin-clipboard-copy

config.js

['@dovyp/vuepress-plugin-clipboard-copy', true]

Apparently, the name mattered. ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cicdw picture cicdw  路  4Comments

fgblomqvist picture fgblomqvist  路  4Comments

joshmeek picture joshmeek  路  4Comments

Trymzet picture Trymzet  路  4Comments

orcaman picture orcaman  路  3Comments