Bookmarklet: cards Markup Link Bookmarklet

Updated . Posted . Visible to the public.

The cards editor has a feature "Cite other card" to create links to other cards in the same deck as mardown links.
If you want to reference a card from a different deck, this bookmarklet might be useful:

javascript:(function () {
  const doAlert = () => { alert("Maybe not a makandra card?") };
  let cardsPathPattern = /(\/[\w-]+\/\d+)-.+/;
  if (window.location.pathname.match(cardsPathPattern)) {
    let currentPath = window.location.pathname.match(cardsPathPattern)[1];
    let title = document.querySelector('h1.note--title')?.textContent;
    if (title) {
      prompt("Your markdown link:", `[${title}](${currentPath})`);
    } else {
      doAlert();
    }
  } else {
    doAlert();
  }
})();

In Firefox you can save this as a bookmarklet:

  1. right-click the die Bookmarks-Toolbar
  2. Add bookmark...
  3. Fill in Name: Card Markup Link Bookmarklet
  4. Fill URL with the Codeblock above
  5. save

When you're on a card and press the bookmark, an alert will give you the link to it in markdown format.

Daniel Straßner
Last edit
Daniel Straßner
License
Source code in this card is licensed under the MIT License.
Posted by Daniel Straßner to makandra dev (2022-12-05 08:51)