Better (human-readable) asset name

This is technically possible with custom.js.

Copy the below to your custom.js file, and with a hiccup (e.g. img file), you can insert a “universal” image using [:img {:src "../assets/img.png" :class universal}] and the image should show up even on another computer.

const observer = new top.MutationObserver(()=>{
const graph = logseq.api.get_current_graph();
let currPath = document.querySelector(".universal");
if (currPath) {
currPath = graph.path + "/" + currPath.src.substring(currPath.src.indexOf("/assets"));
document.querySelector(".universal").src = currPath;
} 
});

observer.observe(top.document.getElementById("app-container"), {
    attributes: false,
    childList: true,
    subtree: true,
});
1 Like