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

Move copy code buttons to JavaScript for better RSS feed compatibility #106

Closed
imfing opened this issue Sep 28, 2023 · 0 comments
Closed
Labels
enhancement New feature or request
Milestone

Comments

@imfing
Copy link
Owner

imfing commented Sep 28, 2023

Currently, the "copy code" buttons are created in advance and included directly in the HTML. This approach has a downside: it adds SVG icons to every code block, which messes up how the RSS feed looks.

<button class="code-copy-btn group/copybtn transition-all active:opacity-50 bg-primary-700/5 border border-black/5 text-gray-600 hover:text-gray-900 rounded-md p-1.5 dark:bg-primary-300/10 dark:border-white/10 dark:text-gray-400 dark:hover:text-gray-50" title="Copy code" data-clipboard-target="#code-block-{{ .Ordinal }}">
{{ partial "utils/icon.html" (dict "name" "copy" "attributes" "class=\"group-[.copied]/copybtn:hidden pointer-events-none h-4 w-4\"") }}
{{ partial "utils/icon.html" (dict "name" "check" "attributes" "class=\"hidden group-[.copied]/copybtn:block success-icon pointer-events-none h-4 w-4\"") }}
</button>

A better way to handle this is to shift the "copy code" button creation to the assets/js/code-copy.js file. By doing this, the buttons get added dynamically when the page loads, avoiding any issues with the RSS feed.

@imfing imfing added the enhancement New feature or request label Sep 28, 2023
@imfing imfing added this to the v0.5.0 milestone Sep 28, 2023
@imfing imfing closed this as completed Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant