Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "copy" button to code in tutorials #213

Closed
jlowin opened this issue Sep 15, 2018 · 16 comments · Fixed by #1409
Closed

Add "copy" button to code in tutorials #213

jlowin opened this issue Sep 15, 2018 · 16 comments · Fixed by #1409
Labels
docs needs:contributor This issue needs someone to work on it

Comments

@jlowin
Copy link
Member

jlowin commented Sep 15, 2018

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.

@jlowin jlowin added the docs label Sep 15, 2018
@cicdw
Copy link
Member

cicdw commented Sep 19, 2018

Relevant: vuejs/vuepress#703

@cicdw cicdw added the blocked label Nov 15, 2018
@dovy
Copy link

dovy commented Mar 25, 2019

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.

@cicdw
Copy link
Member

cicdw commented Mar 25, 2019

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

@cicdw
Copy link
Member

cicdw commented Mar 25, 2019

@dovy do you plan to make this npm installable?

@dovy
Copy link

dovy commented Mar 25, 2019

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.

@dovy
Copy link

dovy commented Mar 25, 2019

@jlowin
Copy link
Member Author

jlowin commented Mar 25, 2019

This is so great! Thanks @dovy!

@dovy
Copy link

dovy commented Mar 25, 2019

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

@cicdw
Copy link
Member

cicdw commented Mar 25, 2019

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.

@dovy
Copy link

dovy commented Mar 25, 2019

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

@cicdw cicdw added the needs:contributor This issue needs someone to work on it label Mar 26, 2019
@ngansequitur
Copy link

@cicdw i can take a look into this!

@dovy
Copy link

dovy commented Mar 27, 2019

@cicdw @itsngansense you can take a look here to see it fully working.

https://docs.redux.io/
https://github.com/reduxframework/docs

Files of note:
https://github.com/reduxframework/docs/@dovyp/plugin-clipboard-copy
https://github.com/reduxframework/docs/blob/master/docs/.vuepress/config.js#L67

@jlowin
Copy link
Member Author

jlowin commented Mar 27, 2019

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

@dovy
Copy link

dovy commented Mar 27, 2019

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. ;)

@jlowin
Copy link
Member Author

jlowin commented Mar 27, 2019

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

@dovy
Copy link

dovy commented Mar 27, 2019

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. ;)

znicholasbrown pushed a commit to znicholasbrown/prefect that referenced this issue Aug 27, 2019
znicholasbrown pushed a commit to znicholasbrown/prefect that referenced this issue Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs needs:contributor This issue needs someone to work on it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants