2

Ueditor编辑器为超链接增加nofollow功能

 3 years ago
source link: https://www.lanka.cn/Ueditor-nofollow_4478.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Ueditor编辑器为超链接增加nofollow功能

2021-04-26 09:14

3819

0

查询失败

前言

经常在发布文章的时候会加入第三方网站的URL链接,超链接最主要还是方便用户直接跳转,但是外链在一定程度上会流失一些权重,所以就考虑为内容里面的超链接增加「nofollow」功能。

2206840705.jpg

修改过程

文件路径:ueditor/dialogs/link 目录

文件名:link.html

1、在链接弹出窗口增加「nofollow」选项

<tr>
<td colspan="2">
<label for="target">
<var id="lang_input_target"></var>
</label>
input id="target" type="checkbox"/>
</td>
</tr>
<tr>
    <td colspan="2">
        <label for="rel">是否加nofollow</label>
        <input id="rel" type="checkbox"/>
    </td>
 </tr>

2、代码增加「nofollow」功能

 function handleDialogOk()

在此函数里增加如下代码

'rel': $G("rel").checked ? "nofollow" : '',

OK 我们继续操作

3、JS文件修改

文件目录:ueditor

文件名:ueditor.config.js

“// xss过滤白名单 名单来源: https://raw.githubusercontent.com/leizongmin/js-xss/master/lib/default.js”
a:      ['target', 'href', 'title', 'class', 'style','rel'],

结尾

通过以上修改,可以通过自行控制是否添加nofollow功能,不用再手动修改了。

the-end.png
  • avatar_3.png匿名
  • avatar_1.png匿名
  • avatar_2.png匿名
  • avatar_0.pngchao.fun
  • avatar_2.png匿名

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK