Hexo打造可以自由配置的网站通知和页面通知
·
大约 400 个字
·
预计 2
分钟 读完
最近本站要更换域名,所以我就想做一个首页和文章内通知,于是就有了这篇文章。
首先打开 theme/next/layout/_layout.swig
文件找到如下代码中的 content-wrap
节点。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| <main id="main" class="main">
<div class="main-inner">
<div class="content-wrap">
<div id="content" class="content">
{% block content %}{% endblock %}
</div>
{% include '_third-party/duoshuo-hot-articles.swig' %}
{% include '_partials/comments.swig' %}
</div>
{% if theme.sidebar.display !== 'remove' %}
{% block sidebar %}{% endblock %}
{% endif %}
</div>
</main>
|
在 content-wrap
节点中添加下面代码
1
2
3
4
5
6
7
8
9
10
11
12
13
| {% if theme.main_notify.enable%}
{% if theme.main_notify.pageshow %}
{% if page.notify === '' %}
<p class="content-notify marquee">{{ theme.main_notify.notify }}</p>
{% else %}
<p class="content-notify marquee">{{ page.notify }}</p>
{% endif %}
{% elseif page.notify !== '' %}
<p class="content-notify marquee">{{ page.notify }}</p>
{% elseif page.title === ''%}
<p class="content-notify marquee">{{ theme.main_notify.notify }}</p>
{% endif %}
{% endif %}
|
上面这段代码的逻辑是判断是否要显示通知,我们实际的通知布局只就是 <p>
标签。
1
| <p class="content-notify marquee">通知的内容</p>
|
阅读更多