zolrath / obsidian-auto-link-title

Automatically fetch the titles of pasted links
MIT License
415 stars 55 forks source link

Feature Request: Add a flag to trim website names #115

Open Martin-Milbradt opened 2 months ago

Martin-Milbradt commented 2 months ago

E.g. The Trillion Dollar Equation - YouTubeThe Trillion Dollar Equation

Code snippet:

text = text.split(/[|—–]|( - )|( · )/)[0].trim();

Open Issue: Some sites (like GitHub) prepend site names, forcing manual workarounds: GitHub - zolrath/obsidian-auto-link-title: Automatically fetch the titles of pasted links

Ugly workaround:

const textArr = text.split(/[|—–]|( - )|( · )/); // Remove site name
text = textArr[0] == "GitHub" ? textArr[textArr.length - 1] : textArr[0]; // GH leads the title
jose-elias-alvarez commented 2 months ago

I'm also interested in this feature, and I wonder if it might make sense to handle the general case as well as specific websites. I suspect this is what Bear does under the hood, since it not only handles YouTube and Github but also transforms Amazon page titles intelligently.

This plugin:

CleanShot 2024-05-03 at 15 00 12

Bear:

CleanShot 2024-05-03 at 14 59 31

I'm happy to put in a PR if there's interest in either approach. One downside I can see to handling specific sites is that it'll likely result in an increased number of PRs adding support for more sites.

Related: #23

burninester commented 2 months ago

This would be a great feature to be added, and I'd like to highlight that if you use the link favicons plugin, then the website name being included in the title becomes even more redundant since you can see the image of the website next to the link. Personally I prefer the favicon instead of the website name and would like an option to remove website names.

Example: image