medic / cht-docs

Documentation site for the Community Health Tookit
https://docs.communityhealthtoolkit.org
13 stars 17 forks source link

Add copy to clipboard button for code snippets #977

Closed eljhkrr closed 1 week ago

eljhkrr commented 1 year ago

While going through the v4 setup guide, I had to manually copy text blocks containing shell commands: image It would be very useful if users could have a copy to clipboard button to grab the whole set of commands at a go like in the example below: image There are a number of workarounds both in the hugo ecosystem and using vanilla JS that can be adopted to add this functionality. A few examples: https://digitaldrummerj.me/hugo-add-copy-code-snippet-button https://www.dannyguo.com/blog/how-to-add-copy-to-clipboard-buttons-to-code-blocks-in-hugo/

eljhkrr commented 5 months ago

Copy code snippet is available in docsy v0.6.0+ https://github.com/google/docsy/pull/1447 https://www.docsy.dev/docs/adding-content/lookandfeel/#code-highlighting-with-chroma

esthermmoturi commented 1 week ago

Done!