Skip to content

Conversation

@JECaballeroR
Copy link

Adding a logo is as simple as:

  1. Add the link to the image as a constant:
    const PAGE_LOGO = 'link to the image';
  2. Modify the MetaRewritter class to:
class MetaRewriter {
  element(element) {
 if (PAGE_TITLE !== '') {
 if (element.getAttribute('property') === 'og:title'
        || element.getAttribute('name') === 'twitter:title') {
        element.setAttribute('content', PAGE_TITLE);
      }
 if (element.tagName === 'title') {
        element.setInnerContent(PAGE_TITLE);
      }
    }
 if (element.getAttribute('property') === 'og:image'
      || element.getAttribute('name') === 'twitter:image') {
      element.setAttribute('content', PAGE_LOGO);}
 if (PAGE_DESCRIPTION !== '') {
 if (element.getAttribute('name') === 'description'
        || element.getAttribute('property') === 'og:description'
        || element.getAttribute('name') === 'twitter:description') {
        element.setAttribute('content', PAGE_DESCRIPTION);
      }
    }
 if (element.getAttribute('property') === 'og:url'
      || element.getAttribute('name') === 'twitter:url') {
      element.setAttribute('content', MY_DOMAIN);
 
    }
 if (element.getAttribute('name') === 'apple-itunes-app') {
      element.remove();
    }
  }
}

This image will become the page's logo, so it should display on the browser and when sharing the site (most of the time, at least. Some apps will render Notion's data, others will render the one after applying the MetaRewritte).

You can use the logo of the Notion page for this too btw, no need to host the logo in a different place.

I used the link to Fruition's logo on the project's site to make the example.

Even if this is not Merged, I suppose posting it might help someone!

@almeidamarcell
Copy link

Excellent. Just tested and works like a charm :)

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

Successfully merging this pull request may close these issues.

2 participants