0x7b1 / logseq-plugin-automatic-url-title

MIT License
50 stars 16 forks source link

Icons for file:// urls #6

Open playerofgames opened 1 year ago

playerofgames commented 1 year ago

For local file URLs, there is no favIcon, but there is a blank space.

I can think of a couple of options for this:

1) no favicon (and no space) 2) generic icon for file (or even look at the extension)

I've gone with the second option, using

function getIconSrc(href) {
    if (href.startsWith("file:")) {
        return "data:image/svg+xml,%3Csvg width='24' height='24' fill='none' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M18.5 20a.5.5 0 0 1-.5.5H6a.5.5 0 0 1-.5-.5V4a.5.5 0 0 1 .5-.5h6V8a2 2 0 0 0 2 2h4.5v10Zm-5-15.379L17.378 8.5H14a.5.5 0 0 1-.5-.5V4.621Zm5.914 3.793-5.829-5.828c-.026-.026-.058-.046-.085-.07a2.072 2.072 0 0 0-.219-.18c-.04-.027-.086-.045-.128-.068-.071-.04-.141-.084-.216-.116a1.977 1.977 0 0 0-.624-.138C12.266 2.011 12.22 2 12.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9.828a2 2 0 0 0-.586-1.414Z' fill='%23808080'/%3E%3C/svg%3E";
    }
    const { hostname } = new URL(href);
    return `https://www.google.com/s2/favicons?domain=${hostname}&sz=32`;
}

with an embedded SVG outline icon from Fluent, but a local assets might be better.

Screenshot 2022-08-05 at 11 56 19 Screenshot 2022-08-05 at 11 56 15
0x7b1 commented 1 year ago

Hey! thanks for the suggestion. I will definitely include it in the next release :)

cquwyz commented 1 year ago

Where can I use these codes to configure? Or do I just have to wait for the next version update?