Share Link Shortener

Summary

:discourse2: Summary Adds a checkbox in the share link modal that replaces the share link with a shorter version containing only the IDs of the topic and post.
:eyeglasses: Preview Share Link Shortener preview
:hammer_and_wrench: Repository https://github.com/discourse/discourse-share-link-shortener/
:question: Install Guide How to install a theme or theme component
:open_book: New to Discourse Themes? Beginnerā€™s guide to using Discourse Themes

Install this theme component

This theme component is especially useful when sharing Discourse links on platforms that limit the maximum number of characters in a message, like Twitter or Mastodon.

Settings

remember preference: Remember if the user prefers shorter links using their browserā€™s local storage.

Translations:

short_link_label: The toggle label, set to ā€œShort linkā€ by default.

Screenshots & video

Short link off

Short link on

In action:


:information_source: This feature was requested here: Post Sharing - ability to convert the URL to the short version

27 Likes

That is pretty sweet! Thanks for making this!

3 Likes

Thank you so much for making this very useful theme component <3

4 Likes

I noticed a slight issue. The checkbox creation prevents the link text input content from being selected by default, and unfortunately, I donā€™t know how to fix itā€¦

Thatā€™s a minor issue though. :slight_smile:

2 Likes

Shouldnā€™t the shortened link also include slug placeholder like this:

https://meta.discourse.org/t/-/251965/4

Iā€™m pretty sure there used to be issues when linking to the forum from external sites using the shortened link without the slug?

3 Likes

Iā€™m not aware of these issues.

I remember seeing the formatting without any slug in a piece of official code yesterday or the day beforeā€¦ I donā€™t remember where but I thought ā€œhow, they use the syntax without the /-/ hereā€ which seemed to be a clue that such URLs seem to be fine. :thinking:

If you happen to find a link about potential problems, that would be great :+1:

2 Likes
1 Like

Thanks!

Either Iā€™m not understanding the issue, or itā€™s not happening anymore. :slight_smile:

Clicking https://meta.discourse.org/t/1 opens the right topic seamlessly and allows you to go back to the previous URL.

No issue either with external links: https://unicyclist.com/t/265354/2608

2 Likes

That link ia almost 2 years old now. I imagine that may have been fixed up since then.

If you look at the op statement it was more about a post number.

The top link has /1 where as the other just ends in / so no post number in the link

(Share Link Shortener) This link goes to post #1 in this topic.

https://meta.discourse.org/t/251965/1

(Share Link Shortener) This link has no post number.

https://meta.discourse.org/t/251965/
2 Likes

You can add more customization to use external shortlink systems, for example I am currently using yourl source code to set-up a website that supports shortlink is https://agentc.asia/s

I loved so much what you did
but I needed to put an icon next to the date
to signal to users that they can click
How do I put an icon there?

@Canapin

1 Like

This suddenly stopped working on my site (to be honest I have no idea when, I donā€™t use it frequently) but just noticed now itā€™s not appearing on any of my themes though itā€™s still enabled on all of them. I know that provides no useful information lol, but any idea?

After upgrading to the latest version of Discourse, I confirm the component doesnā€™t work anymore.
Iā€™d need to have a look at the recent Discourse commits.

Itā€™s a very simple theme component, so if someone wants to have a look and do a PR, itā€™s also welcomed. :slight_smile:

1 Like

This seems like a useful component, so Iā€™ve fixed it and added some updates here:

image

7 Likes

The theme component has been updated and is now official. :slight_smile:
Thereā€™s a new setting as well described in the first post.

Iā€™ve been using Mastodon recently on an instance with limited character numbers, so that might be useful here indeed. :smile:

3 Likes

Shoud these two shares, topic and post, work similar way?

2 Likes
  1. Post link : yes, it does.

  2. Topic linkā€¦ It triggers a JS error :scream: Thanks for thinking about that @Jagster :+1:

1 Like

Interesting, kind of. An error opens sharing of iOS instead. Well, not sharing-sharing actually, but this pop-up:

After trying again, it doesnā€™t trigger any error anymore.

Iā€™m not sure what the issue was.

I donā€™t know anything about errors, but I get different view, and I donā€™t know if it should or should not be that way.

1 Like