Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 committed Nov 7, 2023
1 parent b71c94a commit 8306a1a
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
67 changes: 67 additions & 0 deletions website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@svgr/webpack": "^6.0.0",
"axios": "^0.27.2",
"classnames": "^2.3.1",
"clipboard": "^2.0.11",
"clsx": "^1.1.1",
"color": "^3.1.2",
"core-js": "^3.20.0",
Expand Down
26 changes: 26 additions & 0 deletions website/static/js/headerLinkCopy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import ClipboardJS from 'clipboard';

document.addEventListener("DOMContentLoaded", function () {
// Get all the headers with anchor links
const headers = document.querySelectorAll("a.anchor-header");

headers.forEach((header) => {
header.style.cursor = "pointer";
const clipboard = new ClipboardJS(header, {
text: function(trigger) {
const anchorLink = trigger.getAttribute('href');
return window.location.href.split('#')[0] + anchorLink;
}
});

clipboard.on('success', function(e) {
// Provide user feedback (e.g., alert or tooltip) here
// You can customize the feedback based on your preference
alert("Link copied to clipboard: " + e.text);
});

clipboard.on('error', function(e) {
console.error("Unable to copy to clipboard: " + e.text);
});
});
});

0 comments on commit 8306a1a

Please sign in to comment.