2步搞定hexo文章设置加密访问


title: hexo文章设置加密访问
date: 2020-01-15 11:36:00
tags:

  • hexo

categories:

  • hexo

点击查看实现效果图
具体实现方法:

1.打开themes->next->layout->_partials->head.swig文件,在以下位置插入这样一段代码:

在这里插入图片描述

代码如下:

<script>
    (function(){
        if('{{ page.password }}'){
            if (prompt('请输入文章密码') !== '{{ page.password }}'){
                alert('密码错误!');
                history.back();
            }
        }
    })();
</script>

2.然后在文章上写成类似这样:

在这里插入图片描述

发布了128 篇原创文章 · 获赞 10 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/wcc178399/article/details/103985916