Add new link on header beside search icon

(Anders Thengs Kristensen) #45

I’ve recently added this to our site, but I wanted it to disappear on mobile if there wasn’t enough space to display the icons on the same row as everything else.

As I couldn’t find anything here about that spesific scenario, I tried my hands at it and ended up with

@media (max-width: 350px){
    i.home-button-icon {
        display: none !important;

which seems to do the trick.

Hope this can be helpful to someone.


I did try this to add a link to our Teamspeak server using the application link ts3server:// But the link is not working, got redirect to the 404 page. I did add ts3server to allowed href schemes.

Is this not possible?

(Jose C Gomez) #47

Trying to use a font in the font-awesome list that is not available in the version that comes with Discourse. Adding the CDN Script to the header fixes that issue, but it breaks other fonts that Discourse uses.

Looks like the discourse ones use -o at the end of the class fa-xx-o and that doesn’t work with the FontAwesome CDN script, in develoepr mode I can modify the class from fa-xx-o to fa-xx and it works…
Anybody have any ideas how I can use the newer awesome font but not break the existing stuff?

(Jose C Gomez) #48

I was able to get around this via CSS by using SVG to re-create the logo I needed. For future reference here’s what I did.

Use the above plugin to add the button and link to my Patreon site

<script type="text/discourse-plugin" version="0.4">
api.decorateWidget('header-icons:before', helper => {
    return helper.h('li', [
        helper.h('a#home-button.icon', {
            title: 'Become a Patron!'
        }, helper.h('i.fab.fa-patreon.home-button-icon.d-icon')),

Use CSS Kung-Fu to encode an SVG of the Patreon logo into the new button

.fa-patreon:before {
    content: url("data:image/svg+xml; utf8,");

The above CSS is just an encoded SVG like the one below

<svg width='32px' height='32px' viewBox='0 0 569 546' version='1.1' xmlns=''><title>Patreon logo</title><g><circle data-color='1' id='Oval' cx='362.589996' cy='204.589996' r='204.589996' fill='#F96854' ></circle><rect data-color='2' id='Rectangle' x='0' y='0' width='100' height='545.799988' fill='#052D49'></rect></g></svg>

(Jeff Atwood) #49

Why not simply use a very high resolution PNG? It would be far easier and it’ll compress down extremely well due to the limited palette and geometric shapes.

(Jose C Gomez) #50

@codinghorror it was more a challenge than anything else seeing if I could do it with an SVG since the font-awesome wasn’t working for me.
But yes I agree the PNG would have worked just fine.


(Hamza Ahmed) #51

Hi, Thanks for the tip. Can you please tell me how to print string beside icon. Thanks