如何在博客帖子中添加自动跳转

How To Add Automatic Jump Breaks In Blogger Posts

我知道我的问题对您来说听起来很奇怪,但实际上我不会问如何在 Blogger 中创建自动阅读更多摘要或 post 摘录。因为有多个教程可以在索引页面上的博客中添加 post 摘录。问题是 post 仍然完全加载页面,这使得博客变慢了。我有一个包含 120 多个 post 的博客,我无法通过转到 post 编辑器在其中单独添加跳转符。有没有其他方法可以在 posts 中自动添加跳转符(可以通过 post 编辑器添加的实际跳转符,而不是 post 摘录阅读更多按钮)在索引页面上? 谢谢

您将需要使用新的 snippet 运算符。这将允许您仅加载索引页面(又名主页、分页页面)上 post 内容的摘要(通过 length 属性 控制)替换 [= 的实例13=] 使用以下代码 -

<b:if cond='data:blog.pageType not in {"static_page", "item"}'>
  <b:eval expr='snippet(data:post.body, {length: 450, linebreaks: false, links: false})' />
  <a expr:href='data:post.url + &quot;#more&quot;' ><data:post.jumpText/></a>
<b:else/>
  <data:post.body/>
</b:if>

有关 snippet 运算符的更详细文档 -

snippet(string, options)

Produces a short snippet from an HTML string.

options: Object specifying the snippeting options, which are:

  • links: boolean for whether to preserve anchors/links in the snippet. Defaults to true.
  • linebreaks: boolean for whether to preserve linebreaks (tags) in the snippet. Defaults to true.
  • ellipsis: boolean for whether to append an ellipsis (…) to the end of the snippet. Defaults to true.
  • length: Number specifying the maximum length of the snippet.