-
Notifications
You must be signed in to change notification settings - Fork 304
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 code copy button to all code fields in the blog #81
Conversation
Can someone explain why checks are failing? I am using this successfully in Gitlab CI and with local hugo server |
@Sieboldianus, take a look at this. 12:13:54 PM: Error: failed to prune cache "assets": remove /opt/build/repo/exampleSite/resources/_gen/assets/js/js/main.js_d11fe7b62c27961c87ecd0f2490357b9.content: no such file or directory Also check this out gohugoio/hugo#5745 |
Thanks! I still don't get it:
Netlify complains about the file |
Well, just saw that the original branch has the same problem: That's why shows broken sign on main page. So this seems not a problem with this PR. |
I've tried to remove
Somehow to be expected: to build resources folder, hugo extended is needed. I have no experience with netlify, so maybe someone else can solve this problem. |
5e37b35
to
d2c0991
Compare
According to, this can only be fixed by the project maintainer by switching to Xenial Image in the Netlify Dashboard.
There's a closed issue on Netlify that is addressing this. After that, remove resouces folder and let it build by Netlify hugo extended. |
@Sieboldianus I have no experience with web development at all. But, I think I understand the problem now! |
@Track3 Can you use |
@Sieboldianus I have one question. Can I turn off that |
I can't since I have no access to the repository netlify dashboard, this needs to be done by the maintainer of this repository.
Simplest way to disable the feature is to override default behaviour of showing code copy button, e.g.:
… would be overridden by:
where you removed the following line see:
The other way around would be to make code-copy button optional by removing the line above in the master branch. |
I've switched to Ubuntu Xenial build image, but it still won't build. I think it has something to do with "hugo --gc" command, you can try to edit |
@Sieboldianus Is it possible to enable or disable the |
Will look into this as soon as possible! Many thanks |
I'll consider adding this option to the PR, need to look into this.. |
@Sieboldianus Can you also make the button have 50% opacity? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that is nice!
Update compiled scss add minified version of code-copy.js to resources
Add code copy button to code fields Update compiled scss
Update compiled style.scss Revert "Update compiled style.scss" This reverts commit 9a0a5e99ad2c038f81e1f3c1c54f7b570ec74d80. Add transparency to code-copy button Add code-copy-button option to config.toml Update resource assets Remove code-copy.js_d11fe7b62c27961c87ecd0f2490357b9.content Fix netlify ci with .content files in assets Fix netlify ci with .content files in assets
059bfda
to
ee7a643
Compare
Ok, some final work on this PR:
From my perspective it looks like the PR is ready for merge into master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A massive thanks to everyone involved! I just noticed this will only work with codefences, not with Hugo highlight shortcode. Shall we add support for that? I think for now, we can just merge this and improve this feature later.
This PR adds a code copy button to all code fields in the blog.
Note:
I have a blog with lots of code fields and thought this was helpful for users who want to follow code examples. The actual code is from Tom Spencer and properly referenced. I have recompiled the scss in assets folder, so this can be used without the extended version.