feat: boardcast

This commit is contained in:
沈宇 2020-09-01 10:47:02 +08:00
parent c775133f5b
commit 83b79e97c1
4 changed files with 61 additions and 0 deletions

View File

@ -121,6 +121,12 @@ cover:
# ProgressBar # ProgressBar
progressBar: true progressBar: true
# Boardcast
broadcast:
enable: true
type: 2 # 1custom2hitokoto api(https://hitokoto.cn/)
text: a clean and elegant theme, fast and responsive. # only work in custom mode
# Article Setting # Article Setting
# (Use this to excerpt if article is too long<!--more-->) # (Use this to excerpt if article is too long<!--more-->)
excerpt_link: Read More... excerpt_link: Read More...

View File

@ -35,6 +35,12 @@ cover:
# 页面顶部进度条 # 页面顶部进度条
progressBar: true progressBar: true
# 告示板模块
broadcast:
enable: true # true开启false关闭
type: 2 # 1自定义输入2一言api(https://hitokoto.cn/)
text: 一个安静优雅的hexo主题快速且响应式。 # type为1时有效
# 文章配置 # 文章配置
# 文章太长,截断按钮文字(在需要截断的行增加此标记:<!--more-->) # 文章太长,截断按钮文字(在需要截断的行增加此标记:<!--more-->)
excerpt_link: 阅读更多... excerpt_link: 阅读更多...

View File

@ -1,4 +1,7 @@
<section class="outer"> <section class="outer">
<% if (theme.broadcast.enable && pagination == 2){ %>
<%- partial('_partial/broadcast') %>
<% } %>
<article class="articles"> <article class="articles">
<% <%
var title = ''; var title = '';

View File

@ -0,0 +1,46 @@
<% if (theme.broadcast.type===1 && theme.broadcast.text){ %>
<div class="notice" style="margin-top:50px">
<i class="ri-heart-fill"></i>
<div class="notice-content"><%= theme.broadcast.text %></div>
</div>
<% } %>
<% if (theme.broadcast.type===2){ %>
<div class="notice" style="margin-top:50px">
<i class="ri-heart-fill"></i>
<div class="notice-content" id="broad"></div>
</div>
<script type="text/javascript">
fetch('https://v1.hitokoto.cn')
.then(response => response.json())
.then(data => {
document.getElementById("broad").innerHTML = data.hitokoto;
})
.catch(console.error)
</script>
<% } %>
<style>
.notice {
padding: 20px;
border: 1px dashed #e6e6e6;
color: #969696;
position: relative;
display: inline-block;
width: 100%;
background: #fbfbfb50;
border-radius: 10px;
}
.notice i {
float: left;
color: #999;
font-size: 16px;
padding-right: 10px;
vertical-align: middle;
margin-top: -2px;
}
.notice-content {
display: initial;
vertical-align: middle;
}
</style>