Skip to content
Discussion options

You must be logged in to vote

OH MY GOARSH! I can't believe it's this simple.

// The following block adds a new button next to the buttons described at https://squidfunk.github.io/mkdocs-material/setup/adding-a-git-repository/#code-actions
// The new button copies the current page URL to clipboard
// Customization required:
//   - this depends on "OCTICONS_LINK_16_SVG", which is set in main.html
//   - this depends on "site_url" from mkdocs.yml

const site_url = "https://insert site_url here"
const anchor = document.querySelectorAll("a.md-content__button")[0];
const newAnchor = document.createElement("a");
newAnchor.id = "copy-canonical-url-button";
newAnchor.href = "#";
newAnchor.classList = anchor.classList;
newAnchor.

Replies: 2 comments 4 replies

Comment options

alexvoss
Mar 3, 2024
Collaborator Sponsor

You must be logged in to vote
3 replies
@ryran
Comment options

@alexvoss
Comment options

alexvoss Mar 3, 2024
Collaborator Sponsor

@ryran
Comment options

Answer selected by ryran
Comment options

You must be logged in to vote
1 reply
@alexvoss
Comment options

alexvoss Mar 3, 2024
Collaborator Sponsor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants