Skip to content

Commit 9a93b36

Browse files
authored
Merge pull request #1 from zhheo/master
添加nofollow
2 parents c947512 + e201de0 commit 9a93b36

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

moments.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ let orign_data = []; //api请求所得到的源数据
44
let maxnumber = 20; //页面展示文章数量
55
let addnumber = 10; //每次加载增加的篇数
66
let opentype = '_blank'; //'_blank'打开新标签,'_self'本窗口打开
7+
let nofollow = true //禁止搜索引擎抓取
78

89
//将html放入指定id的div容器
910
let append_div = (parent, text) => {
@@ -149,18 +150,27 @@ let data_handle = (data, maxnumber) => {
149150
html_item += '<div class="moments_chart"><span class="moments_post_info_title">活跃友链数:</span><span class="moments_post_info_number">' + unique_live_link + '个</span><br><span class="moments_post_info_title">当前库存:</span><span class="moments_post_info_number">' + listlenth + '篇</span><br></div>';
150151
html_item += '<div class="moments_chart"><span class="moments_post_info_title">今日更新:</span><span class="moments_post_info_number">' + today_post + '篇</span><br><span class="moments_post_info_title">最近更新:</span><span class="moments_post_info_number">' + last_update_time + '</span><br></div>';
151152
html_item += '</div>';
153+
152154
for (let month_item of datalist_slice) {
153155
html_item += '<h2>' + month_item[0] + '</h2>';
154156
for (let post_item of month_item[1]) {
157+
var rel = '';
158+
if (nofollow && opentype == '_blank'){
159+
rel = 'noopener nofollow';
160+
}else if(nofollow){
161+
rel = 'nofollow';
162+
}else{
163+
rel = '';
164+
}
155165
html_item += ' <div class="moments-item">';
156-
html_item += ' <a target="' + opentype + '" class="moments-item-img" href="' + post_item[2] + '" title="' + post_item[0] + '">';
166+
html_item += ' <a target="' + opentype + '" class="moments-item-img" href="' + post_item[2] + '" title="' + post_item[0] + '"rel="'+ rel + '">';
157167
html_item += '<img onerror="this.onerror=null,this.src=&quot;https://cdn.jsdelivr.net/gh/Zfour/Butterfly-friend-poor-html/friendcircle/404.png&quot;"';
158168
html_item += ' src="' + post_item[4] + '"></a>';
159169
html_item += '<div class="moments-item-info"><div class="moments-item-time"><i class="far fa-user"></i>';
160170
html_item += '<span>' + post_item[3] + '</span>';
161171
html_item += ' <div class="moments_post_time"><i class="far fa-calendar-alt"></i>' +
162172
'<time datetime="' + post_item[1] + '" title="' + post_item[1] + '">' + post_item[1] + '</time></div>';
163-
html_item += `</div><a target="${opentype}" class="moments-item-title" href="${post_item[2]}" title="${post_item[0]}">${post_item[0]}</a></div>`;
173+
html_item += `</div><a target="${opentype}" class="moments-item-title" href="${post_item[2]}" title="${post_item[0]}"rel="${rel}">${post_item[0]}</a></div>`;
164174
html_item += '</div>';
165175

166176
}

0 commit comments

Comments
 (0)