apostrophe-cms - 从爬虫中排除特定区域
问题描述
我想排除一些特定区域被谷歌等抓取,因为这是法律/隐私,并且会因为长的不相关文本而受到惩罚。所以我找到了iframe的解决方案。htmlRoute
我认为最好的方法是使用或renderRoute
和Disallow: /ROUTE/
在 robots.txt 中为我想要的元素创建一个特定的路线。或者有没有其他推荐的方法来解决这个问题?也许更优雅?
这是我尝试过的代码示例,<!--googleoff: index-->
但不幸的是,这不再起作用:
<footer class="page-footer">
<div class="footer-copyright">
<div class="footer-container">
{%- if data.global.legal -%}
© {{ data.global.creation_date }} {{ data.global.copyright }}
{%- endif -%}
{%- if data.global.privacy -%}
<a class="grey-text text-lighten-4 right modal-trigger" href="#modal-1">privacy</a>
<div id="modal-1" class="modal">
<div class="modal-content text-darken-4">
<!--googleoff: index-->
<h4>Privacy</h4>
{{ apos.area(data.global, 'privacy', {
edit: false,
widgets: { 'apostrophe-rich-text': { } }
}) }}
<!--googleon: index-->
</div>
</div>
{%- endif -%}
{%- if data.global.legal -%}
<a class="grey-text text-lighten-4 right modal-trigger" href="#modal-2">Legal</a>
<div id="modal-2" class="modal">
<div class="modal-content text-darken-4">
<!--googleoff: index-->
<h4>Legal Info</h4>
{{ apos.area(data.global, 'legal', {
edit: false,
widgets: { 'apostrophe-rich-text': { } }
}) }}
<!--googleon: index-->
</div>
</div>
{%- endif -%}
</div>
</div>
</footer>
我renderRoute
从撇号核心模块中选择了一些示例函数并将其实现到我的撇号全局现在我的撇号全局看起来像这样:
...
{
name: 'legal',
label: 'Legal Info',
help: 'Your adress, phone and other info here',
type: 'area',
options: {
widgets: {
'apostrophe-rich-text': {
toolbar: [
'Styles',
'Bold',
'Italic',
'Blockquote',
'BulletedList',
'Link'
],
controls: {
movable: false,
cloneable: false,
removable: true,
position: 'top-right'
}
}
}
}
},
construct: function(self, options) {
self.renderRoute('post', 'iframe', function(req, res, next) {
return next(null, {
template: 'legal'
});
});
}
但是当我打开合法模式时,我仍然没有得到像 iframe 这样的路由。我想我做错了什么或者没有完全理解这个功能。如果您能澄清这一点,我将非常感激。也许这只是一个快速寻找你...
解决方案
googleoff
不适用于公共谷歌爬虫。它严格用于谷歌的旧“搜索工具”,它是用于 Intranet 的,现已停产。
你的 iframe 策略可以奏效。到达那里的最简单方法是通过向 的模式添加一个区域来将内容放入全局首选项中apostrophe-global
,如下所示:
// in lib/modules/apostrophe-global/index.js
module.exports = {
addFields: [
{
name: 'legal',
type: 'singleton',
widgetType: 'apostrophe-rich-text',
options: {
toolbar: [ 'Bold', 'Italic', 'Link' ]
}
}
]
};
然后你可以renderRoute
按照你的建议使用,并渲染一个从全局文档输出该区域的模板。
推荐阅读
- unit-testing - 单元测试如何等待 JavaFX 平台的关闭?
- excel - 自定义 VBA 函数引发意外输出
- python - 为什么此异常打印为“列表索引超出范围”?
- python - tweepy.error.TweepError: [{'code': 50, 'message': 'User not found.'}]
- xamarin.forms - Stacklayout BindableLayout 中的 Xamarin Forms Switch 使用 MVVM (Prism.Forms) 获取切换事件
- python - 为什么内核在训练开始后很快就死掉了?
- sql - 变量声明显着增加查询时间
- python - 有没有办法获取不在列表中的元素的索引?
- python - 无法在地图标记容器内定位元素/单击红点
- reactjs - Nextjs 配置:模块解析失败:意外字符“@”