添加主题自定义配置参数

master
dmxiaoshen 3 years ago
parent 50b1123c4a
commit cb692ea862

@ -2,102 +2,55 @@
"name": "yinwang",
"version": "1.1.0",
"author": "dmxiaoshen",
"repository": "https://git.dmxiaoshen.com/dmxiaoshen/gridea-theme-yinwang",
"customConfig": [
{
"name": "sidebarWidth",
"label": "菜单栏宽度",
"group": "布局",
"value": "320px",
"type": "input",
"note": "可填像素类型320px或百分比类型38.2%"
},
{
"name": "featureBorderRadius",
"label": "封面图圆角",
"group": "布局",
"value": "3px",
"type": "input",
"note": "像素类型3px"
},
{
"name": "menuColor",
"label": "菜单颜色",
"group": "颜色",
"value": "#dee2e6",
"type": "input",
"card": "color",
"note": "颜色字符串:(如:#EEEEEE、rgba(255, 255, 255, 0.9)"
},
{
"name": "contentBgColor",
"label": "内容区背景色",
"group": "颜色",
"value": "#f8f9fa",
"type": "input",
"card": "color",
"note": "颜色字符串:(如:#EEEEEE、rgba(255, 255, 255, 0.9)"
},
{
"name": "renderKaTeX",
"label": "是否渲染 KaTeX 公式",
"group": "渲染",
"name": "hitokoto",
"label": "是否开启Hitokoto一言",
"group": "Hitokoto一言",
"type": "switch",
"value": false,
"type": "switch"
"note": "简单来说,一言指的就是一句话,可以是动漫中的台词,也可以是网络上的各种小段子。 或是感动,或是开心,有或是单纯的回忆。来到这里,留下你所喜欢的那一句句话,与大家分享,这就是一言存在的目的。"
},
{
"name": "renderCode",
"label": "是否渲染代码高亮",
"group": "渲染",
"name": "homeback",
"label": "是否显示返回首页按钮",
"group": "返回首页按钮",
"type": "switch",
"value": false,
"type": "switch"
"note": "关于、标签云、文章页显示返回首页按钮"
},
{
"name": "github",
"label": "Github",
"group": "社交",
"value": "",
"type": "input",
"note": "链接地址"
"name": "showtag",
"label": "文章页是否显示标签",
"group": "文章页显示标签",
"type": "switch",
"value": false,
"note": "每篇文章的底部会显示该文章的标签"
},
{
"name": "twitter",
"label": "Twitter",
"group": "社交",
"value": "",
"type": "input",
"note": "链接地址"
"name": "wordcount",
"label": "是否统计文章字数",
"group": "统计文章字数",
"type": "switch",
"value": false,
"note": "统计每篇文章的字数,会在首页和归档页面呈现"
},
{
"name": "weibo",
"label": "微博",
"group": "社交",
"value": "",
"name": "twikoo",
"label": "evnId",
"group": "Twikoo评论",
"type": "input",
"note": "链接地址"
},
{
"name": "zhihu",
"label": "知乎",
"group": "社交",
"value": "",
"type": "input",
"note": "链接地址"
"note": "请正确获取到Twikoo评论系统的evnId"
},
{
"name": "facebook",
"label": "Facebook",
"group": "社交",
"value": "",
"name": "tversion",
"label": "version",
"group": "Twikoo评论",
"type": "input",
"note": "链接地址"
},
{
"name": "customCss",
"label": "自定义CSS",
"group": "自定义样式",
"value": "",
"type": "textarea",
"note": ""
"note": "填写Twikoo评论系统的版本"
},
{
"name": "ga",

@ -17,3 +17,14 @@
<script src="<%= themeConfig.domain %>/media/js/jquery.min.js" type="text/javascript"></script>
<link rel="alternate" href="/atom.xml" title="<%= siteTitle %>" type="application/atom+xml">
<% if (site.customConfig.ga) { %>
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= site.customConfig.ga %>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<%= site.customConfig.ga %>');
</script>
<% } %>

@ -27,7 +27,9 @@
<ul class="list-group">
<li class="list-group-item title">
<a href="<%= post.link %>" target="_self"><%= post.title %></a>
<div class="word-count2"><%= post.stats.words %>字</div>
<% if (site.customConfig.wordcount) { %>
<div class="word-count2"><%= post.stats.words %>字</div>
<% } %>
<div class="date" style="color:darkgray;font-size:80%"><%= post.dateFormat %></div>
</li>
</ul>
@ -36,9 +38,11 @@
<% }); %>
<h3>&nbsp;</h3>
<%- include('./_blocks/pagination') %>
<div style="text-align: right;">
↶ <a href="/">返回首页</a>
</div>
<% if (site.customConfig.homeback) { %>
<div style="text-align: right;">
↶ <a href="/">返回首页</a>
</div>
<% } %>
</div>
</div>
<%- include('./_blocks/scripts') %>

@ -57,7 +57,9 @@
<li class="list-group-item title">
<div class="date"><%= post.dateFormat %></div>
<a href="<%= post.link %>" target="_self"><%= post.title %></a>
<div class="word-count"><%= post.stats.words %>字</div>
<% if (site.customConfig.wordcount) { %>
<div class="word-count"><%= post.stats.words %>字</div>
<% } %>
</li>
<% }); %>
</ul>

@ -14,12 +14,30 @@
<h2><%= post.title %></h2>
<%- post.content %>
<h3>&nbsp;</h3>
<% post.tags.forEach((tag) => { %>
<a href="<%= tag.link %>">#<%= tag.name %></a>&nbsp;
<% }); %>
<div style="text-align: right;">
↶ <a href="/">返回首页</a>
</div>
<% if (site.customConfig.showtag) { %>
<% post.tags.forEach((tag) => { %>
<a href="<%= tag.link %>">#<%= tag.name %></a>&nbsp;
<% }); %>
<% } %>
<% if (site.customConfig.homeback) { %>
<div style="text-align: right;">
↶ <a href="/">返回首页</a>
</div>
<% } %>
<% if (site.customConfig.twikoo) { %>
<h3>&nbsp;</h3>
<div id="tcomment"></div>
<script src="https://cdn.staticfile.org/twikoo/<%= site.customConfig.tversion %>/twikoo.all.min.js"></script>
<script>
twikoo.init({
envId: '<%= site.customConfig.twikoo %>', // 腾讯云环境填 envIdVercel 环境填地址https://xxx.vercel.app
el: '#tcomment', // 容器元素
// region: 'ap-guangzhou', // 环境地域,默认为 ap-shanghai腾讯云环境填 ap-shanghai 或 ap-guangzhouVercel 环境不填
// path: location.pathname, // 用于区分不同文章的自定义 js 路径,如果您的文章路径不是 location.pathname需传此参数
lang: 'zh-CN', // 用于手动设定评论区语言,支持的语言列表 https://github.com/imaegoo/twikoo/blob/main/src/client/utils/i18n/index.js
})
</script>
<% } %>
</div>
</div>
<%- include('./_blocks/scripts') %>

@ -16,16 +16,20 @@
<ul class="list-group">
<% posts.forEach(function(post) { %>
<li class="list-group-item title"><a href="<%= post.link %>" target="_self"><%= post.title %></a>
<div class="word-count2"><%= post.stats.words %>字</div>
<% if (site.customConfig.wordcount) { %>
<div class="word-count2"><%= post.stats.words %>字</div>
<% } %>
<div class="date" style="color:darkgray;font-size:80%"><%= post.dateFormat %></div>
</li>
<% }); %>
</ul>
<h3>&nbsp;</h3>
<%- include('./_blocks/pagination') %>
<div style="text-align: right;">
↶ <a href="/tags/">标签云</a>
</div>
<% if (site.customConfig.homeback) { %>
<div style="text-align: right;">
↶ <a href="/tags/">标签云</a>
</div>
<% } %>
</div>
</div>

@ -38,16 +38,20 @@
<% }); %>
</ul>
<h3>&nbsp;</h3>
<p id="hitokoto">
<% if (site.customConfig.hitokoto) { %>
<p id="hitokoto">
<div id="hitokoto_text" style="font-size: 90%;"></div>
<div id="hitokoto_from" style="font-size: 50%;"></div>
</p>
<div style="text-align: right;">
↶ <a href="/">返回首页</a>
</div>
</p>
<% } %>
<% if (site.customConfig.homeback) { %>
<div style="text-align: right;">
↶ <a href="/">返回首页</a>
</div>
<% } %>
</div>
</div>
<% if (site.customConfig.hitokoto) { %>
<script>
fetch('https://v1.hitokoto.cn')
.then(response => response.json())
@ -55,15 +59,16 @@
const hitokoto = document.querySelector('#hitokoto_text')
const from = document.querySelector('#hitokoto_from')
//hitokoto.href = `https://hitokoto.cn/?uuid=${data.uuid}`
if( data.from_who){
from.innerText = '————'+ data.from_who + '「'+data.from+'」'
}else{
from.innerText = '————'+ '「'+data.from+'」'
if (data.from_who) {
from.innerText = '————' + data.from_who + '「' + data.from + '」'
} else {
from.innerText = '————' + '「' + data.from + '」'
}
hitokoto.innerText = data.hitokoto
})
.catch(console.error)
</script>
<% } %>
<%- include('./_blocks/scripts') %>
</body>
</html>

Loading…
Cancel
Save