Created
July 9, 2018 10:22
-
-
Save nesterione/c2d8004c5bc7267bdfa40932fff010f9 to your computer and use it in GitHub Desktop.
Telegram instantview template for Ghost blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$main: //*[@id="site-main"]/div/article | |
title: $main/header/h1 | |
body: $main/section[1] | |
author: //*[@id="site-main"]/div/article/footer/section/section/h4/a | |
author_url: "https://vk.com/nesterione" | |
published_date: $main/header/section/time | |
@remove: $main/section[1]/div/iframe[has-class("optional")] | |
### Now we'll set a cover image. It's also not required, but we need one if we want our Instant view page to look cool. | |
@background_to_image: //*[@id="site-main"]/div/article/figure | |
$main_image: $@ | |
# Set the figure as the value of the 'cover' *property*. | |
cover: $main_image | |
### Now to find an image for link previews. Links shared via Telegram will show an extended preview with a small picture in the chat. Let's try to find something for this image. | |
# If we've already got a cover, we'll use it for the link preview image too. | |
image_url: $cover/self::img/@src | |
image_url: $cover/self::figure//img/@src | |
# If we didn't find a cover, we'll take a picture from the meta tags. | |
# Otherwise, the link preview will just have text in it, which is also OK. | |
image_url: //head/meta[@property="og:image"]/@content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment