You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.8 KiB

4 years ago
  1. +++
  2. title = "Instant Views"
  3. description = "Instantly preview your content from within Telegram."
  4. categories = ["social"]
  5. tags = ["author", "templating"]
  6. features = ["related content"]
  7. [[copyright]]
  8. owner = "Josh Habdas"
  9. date = "2019"
  10. license = "agpl-3.0-or-later"
  11. +++
  12. After Dark provides a template guide to enable Telegram Instant Views for posts. Use it to create an {{< external href="https://instantview.telegram.org/my/" text="Instant View Template" />}} on the Telegram site:
  13. ```yaml
  14. # use 2.0
  15. ~version: "2.0"
  16. # enable for items in the post section
  17. ?path: /post/.+
  18. # define required elements
  19. title: //*[@itemprop="headline"]
  20. body: //*[@itemprop="articleBody"]
  21. # add optional site name and subtitle
  22. subtitle: //*[@itemprop="description"][normalize-space()]
  23. site_name: //*[@itemprop="url"][@href="/"]
  24. # if author exists, define name and url
  25. ?exists: //*[@itemprop="author"]
  26. author: //*[@itemprop="author"]
  27. author_url: //*[@itemprop="url"]/@href
  28. # add optional telegram channel
  29. channel: //*[@name="telegram:channel"]/@content
  30. # if cover exists, define images
  31. ?exists: //article/meta[@itemprop="image"]/@content
  32. cover: //article/header/figure[@itemprop="image"]
  33. image_url: $cover/self::img/@src
  34. # post date extracted automatically
  35. ```
  36. Preview your results on the Telegram site:
  37. ![Telegram Instant View screenshot](/images/feature-instant-view-fs8.png "Example Telegram Instant View for After Dark")
  38. Additionally, if your site has a telegram channel, you can specify it by setting the following in your site config:
  39. ```toml
  40. [params.seo]
  41. telegram_channel = "channelname" # omit the leading `@`
  42. ```
  43. Specifying a channel name allows Telegram users to join your channel with a single click from within an Instant View.
  44. See the {{< external href="https://instantview.telegram.org/" text="Instant View on Telegram" />}} for additional information.