Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Martin-Milbradt opened this issue Apr 30, 2024 · 3 comments
Open

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

Martin-Milbradt opened this issue Apr 30, 2024 · 3 comments

Comments

@Martin-Milbradt
Copy link

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
Copy link

jose-elias-alvarez commented May 3, 2024

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
Copy link

burninester commented May 4, 2024

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

@jose-elias-alvarez
Copy link

I got bothered enough by this to implement it into my own plugin, obsidian-paste-link: you can now define page-specific regular expressions to extract page titles. My plugin is overall simpler and doesn't have every feature from auto-link-title, but if you also want finer control over titles, you may want to give it a shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants