hexo-theme-ayer/layout/_partial/broadcast.ejs

46 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-09-01 02:47:02 +00:00
<% 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>