koto's Site 🤪 About me Search Post Tags Archives Friendly sites Switch theme Settings

Telegram Instant View 适配记录

Telegram Instant View 即时预览适配过程记录

2023-10-28 19:45+0800 About 1 mins

 Tagged with:

适配 Telegram Instant View

1. 登入 Telegram Instant View

  1. 打开 https://instantview.telegram.org 并在右下方位置找到 Login 进行登入。
  2. 点开 My Template 并输入网址创建新模板

2. 编写规则

在 RULES 中视自己网站的情况进行编写规则。

~version: "2.1" 
?path: /posts/.+
body: //main 
title: //main//h1
site_name: "koto's site"
author: "kobe-koto" 
author_url: "https://koto.cc/"
published_date: //span[has-class("time-date")] 
@split_parent: //p/img 
@split_parent: //blockquote/img 
@remove: //div[has-class("tags")] 
@remove: //p[has-class("time")] 
@remove: //div[has-class("giscus")] 

内容解释:

  • ~version: "2.1" 使用 2.1 版本的 Instant View
  • ?path: /posts/.+ 规则仅适用于以 /posts/ 开头的网址
  • body: //main<main> 标签中读取文章内容
  • title: //main//h1<main> 标签中的 <h1> 标签中的内容作为标题
  • site_name: "koto's site" 设定网站名称
  • author: "kobe-koto" 设定作者
  • author_url: "https://koto.cc/" 设定作者链接(点击作者会重新导向过去)
  • published_date: //span[has-class("time-date")] 从含有 time-date 类的 <span> 标签中获取文章发布日期
  • @split_parent: //p/img @split_parent: //blockquote/img 将含有 <img><p><blockquote> 拆分
  • @remove: //div[has-class("tags")] 去除包含 tags 类的 <div> 标签
  • @remove: //p[has-class("time")] 去除包含 time 类的 <p> 标签
  • @remove: //div[has-class("giscus")] 去除包含 giscus 类的 <div> 标签

3. 提交审核

要让这个站点应用这个规则,需提交同域名下的10个不同路径的链接。

在看到 Submit Template 亮了之后就可以提交了。