gpt4 book ai didi

javascript - 脚本代码片段显示在博客文章摘要中

转载 作者:行者123 更新时间:2023-11-28 05:11:52 25 4
gpt4 key购买 nike

最近我的博客Sample批准了 Adsense,所以我开始将广告放在帖子的顶部。但这会导致广告代码显示在帖子摘要中,如下所示请看这个ximagex

请帮我弄清楚如何删除它。

Java 脚本代码

<script type='text/javascript'>
//<![CDATA[
//Post Thumbnail Setting
var TemplateismSummary = {
displayimages: false,
imagePosition: 'left',
Widthimg: 200,
Heightimg: 0,
noThumb: 'https://lh3.googleusercontent.com/-GRP8IcURRsw/T9MjiNWXUcI/AAAAAAAAB88/QEDpDHxI55o/s1600/no-thumb.jpg',
SummaryWords: 21,
wordsNoImg: 20,
skipper: 0,
DisplayHome: true,
DisplayLabel: true
};

最佳答案

您将需要使用新引入的 snippet运算符(operator)。这是 Blogger 用于从 HTML 字符串生成片段的 native 方法(在我们的示例中,这是完整的帖子内容)。设置选项linebreakslinksfalse需要完成从通过此运算符生成的代码片段中删除所有 HTML 标签。替换<data:post.body/>的实例使用以下代码 -

<b:if cond='data:blog.pageType not in {"static_page", "item"}'>
<b:eval expr='snippet(data:post.body, {length: 450, linebreaks: false, links: false})' />
<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 thesnippet. Defaults to true.
  • ellipsis: boolean for whether to append an ellipsis to the end ofthe snippet. Defaults to true.
  • length: Number specifying the maximum length of the snippet.

关于javascript - 脚本代码片段显示在博客文章摘要中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41310207/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com