javascriptreactjsmeteortelescope

Display domain url in custom Telescope theme


I am customizing Telescope theme, and what I need is to display domain url from where the post is coming. It should be displayed in PostsItem.

Like it exist on Sidebar.io website, this part.

I asked the other day on Telescope slack channel and this is advice/instructions I got:

Check in nova:posts/helpers there maybe a function to do that automatically. Else based on the string you get from the getDomain function, make it an array divided by /, and take the first argument which will be the domain

That should help I guess, I am just not experienced enough and couldn't make that work. So I still need help with this.

These links could be helpful too: utils.js and helpers.js

I tried to add <h3>{post.url}</h3> inside file CustomPostsItem.jsx but I got full url, instead of just domain.

Thanks in advance!


Solution

  • I got an answer on Telescope slack channel and it works.

    {post.url ? <span className="post-url-domain">{Telescope.utils.getDomain(post.url)}</span> : null}