提交 e6447686 编写于 作者: EvanOne(文一)'s avatar EvanOne(文一)

refactor: Change es6 to es5

上级 f3e48af2
-
let algolia = 'undefined';
let env = process.env;
var algolia = 'undefined';
var env = process.env;
if (theme.algolia_search.enable) {
algolia = JSON.stringify({
......@@ -17,8 +17,8 @@
}
script.
let Stun = window.Stun || {};
let CONFIG = {
var Stun = window.Stun || {};
var CONFIG = {
root: '!{ config.root }',
algolia: !{algolia},
notification: {
......
footer#footer
-
let footer = theme.footer
let nowYear = new Date().getFullYear()
let startYear = footer.copyright.enable ? footer.copyright.since || nowYear : nowYear
let endYear = footer.copyright.enable ? footer.copyright.end || nowYear : nowYear
var footer = theme.footer
var nowYear = new Date().getFullYear()
var startYear = footer.copyright.enable ? footer.copyright.since || nowYear : nowYear
var endYear = footer.copyright.enable ? footer.copyright.end || nowYear : nowYear
div.footer-inner
if footer.copyright.enable || footer.beian.enable
......@@ -31,7 +31,7 @@ footer#footer
div
if footer.powered.enable
span.footer-powered
- let HEXO_URL = "http://hexo.io/";
- var HEXO_URL = "http://hexo.io/";
!= _p("footer.powered", link_to(HEXO_URL, "hexo", { external: true }))
if footer.powered.version
......@@ -42,7 +42,7 @@ footer#footer
if footer.theme.enable
span= _p("footer.theme") + " - "
- let STUN_URL = "https://github.com/liuyib/hexo-theme-stun/";
- var STUN_URL = "https://github.com/liuyib/hexo-theme-stun/";
!= link_to(STUN_URL, "stun", { external: true })
if footer.theme.version
......
-
let pageTitle = page.title || config.subtitle || ""
var pageTitle = page.title || config.subtitle || ""
if (page.type === "tags") pageTitle = _p("title.tags")
if (page.type === "categories") pageTitle = _p("title.categories")
......@@ -11,10 +11,10 @@
pageTitle ? pageTitle += " | " + config.title : pageTitle = config.title
let pageDescription = page.description || page.title || config.description || ""
let pageKeywords = [config.author, config.title, config.keywords].filter(i => !!i).join(", ")
let pageAuthor = config.email ? `${config.author}: ${config.email}` : config.author
let pageCopyright = config.copyright || config.author
var pageDescription = page.description || page.title || config.description || ""
var pageKeywords = [config.author, config.title, config.keywords].filter(i => !!i).join(", ")
var pageAuthor = config.email ? `${config.author}: ${config.email}` : config.author
var pageCopyright = config.copyright || config.author
meta(charset="UTF-8")
meta(http-equiv="X-UA-Compatible" content="IE=edge")
......
......@@ -19,9 +19,9 @@ header#header(
div.header-nav-menu
each value, name in (theme.menu || [])
if name && value
- let menuItem = value.split('||')
- let menuItemPath = _.trim(_.get(menuItem, '[0]'))
- let menuItemIcon = _.trim(_.get(menuItem, '[1]'))
- var menuItem = value.split('||')
- var menuItemPath = _.trim(_.get(menuItem, '[0]'))
- var menuItemIcon = _.trim(_.get(menuItem, '[1]'))
span
a(href=menuItemPath ? menuItemPath : "/")
if !theme.menu_settings.text_only
......
aside#sidebar
div.sidebar-inner
- let isShowPostToc = theme.toc.enable && is_post()
- var isShowPostToc = theme.toc.enable && is_post()
if isShowPostToc
div.sidebar-nav
span.sidebar-nav-toc.current= _p("sidebar.catalog")
......@@ -8,7 +8,7 @@ aside#sidebar
section(class=`${isShowPostToc ? "" : "hide"}`).sidebar-toc
if page.content
- let tocMaxDepth = page.toc_max_depth || theme.toc.max_depth || 6
- var tocMaxDepth = page.toc_max_depth || theme.toc.max_depth || 6
div!= toc(page.content, {list_number: theme.toc.number, max_depth: tocMaxDepth})
section(class=`${isShowPostToc ? "hide" : ""}`).sidebar-overview
......@@ -24,9 +24,9 @@ aside#sidebar
div.sidebar-social
for value, name in (theme.social || [])
if name && value
- let socialItem = value.split('||')
- let socialLinkPath = _.trim(_.get(socialItem, '[0]'))
- let socialLinkIcon = _.trim(_.get(socialItem, '[1]'))
- var socialItem = value.split('||')
- var socialLinkPath = _.trim(_.get(socialItem, '[0]'))
- var socialLinkIcon = _.trim(_.get(socialItem, '[1]'))
span.sidebar-social-item
a(href=socialLinkPath target="_blank" rel="noopener"
data-popover=_p(`social.${name}`) data-popover-pos="up")
......@@ -42,7 +42,7 @@ aside#sidebar
if theme.feed.enable
div.sidebar-feed
- let feedEmail = theme.feed.email
- var feedEmail = theme.feed.email
if feedEmail
span.sidebar-feed-email
a(href=feedEmail target="_blank" rel="noopener")
......@@ -50,7 +50,7 @@ aside#sidebar
span Email
span= _p("sidebar.subscribe")
- let feedRSS = theme.feed.rss
- var feedRSS = theme.feed.rss
if feedRSS
span.sidebar-feed-rss
a(href=url_for(feedRSS) target="_blank" rel="noopener")
......@@ -59,9 +59,9 @@ aside#sidebar
span= _p("sidebar.subscribe")
if theme.menu
- let menuArchives = _.trim(_.get(theme.menu.archives.split('||'), '[0]'))
- let menuCategories = _.trim(_.get(theme.menu.categories.split('||'), '[0]'))
- let menuTags = _.trim(_.get(theme.menu.tags.split('||'), '[0]'))
- var menuArchives = _.trim(_.get(theme.menu.archives.split('||'), '[0]'))
- var menuCategories = _.trim(_.get(theme.menu.categories.split('||'), '[0]'))
- var menuTags = _.trim(_.get(theme.menu.tags.split('||'), '[0]'))
div.sidebar-state
if theme.menu.archives
div.sidebar-state-item.sidebar-state-posts
......@@ -80,10 +80,10 @@ aside#sidebar
div.sidebar-state-item-name= _p("sidebar.tags")
if theme.creative_commons.enable && theme.creative_commons.sidebar
- let themeCC = theme.creative_commons
- let ccLicense = themeCC.license && themeCC.license.toLowerCase()
- let ccLanguage = (themeCC.language && themeCC.language.toLowerCase()) || "en"
- let ccURL = `https://creativecommons.org/licenses/${ccLicense}/4.0/deed.${ccLanguage}`
- var themeCC = theme.creative_commons
- var ccLicense = themeCC.license && themeCC.license.toLowerCase()
- var ccLanguage = (themeCC.language && themeCC.language.toLowerCase()) || "en"
- var ccURL = `https://creativecommons.org/licenses/${ccLicense}/4.0/deed.${ccLanguage}`
div.sidebar-cc
a(href=ccURL target="_blank" rel="noopener"
data-popover="Creative Commons" data-popover-pos="up")
......
-
let themeCC = theme.creative_commons
let ccLicense = themeCC.license && themeCC.license.toLowerCase()
let ccLanguage = (themeCC.language && themeCC.language.toLowerCase()) || "en"
let ccURL = `https://creativecommons.org/licenses/${ccLicense}/4.0/deed.${ccLanguage}`
var themeCC = theme.creative_commons
var ccLicense = themeCC.license && themeCC.license.toLowerCase()
var ccLanguage = (themeCC.language && themeCC.language.toLowerCase()) || "en"
var ccURL = `https://creativecommons.org/licenses/${ccLicense}/4.0/deed.${ccLanguage}`
div.post-footer-copyright
div.copyright-author
......
-
let options = {
var options = {
prev_text: '<i class="fa fa-chevron-left"></i>',
next_text: '<i class="fa fa-chevron-right"></i>',
mid_size: 1
......
section#recent-posts
- let postLists = theme.post_list.paginate.home ? page.posts : site.posts
- var postLists = theme.post_list.paginate.home ? page.posts : site.posts
- postLists.each(function (post) {
article.post-item
+postHeader(post)
......@@ -12,7 +12,7 @@ section#recent-posts
if theme.auto_excerpt && theme.auto_excerpt.enable
- const content = strip_html(post.content)
- let excerpt = content.substring(0, theme.auto_excerpt.length)
- var excerpt = content.substring(0, theme.auto_excerpt.length)
- content.length > theme.auto_excerpt.length ? excerpt += '......' : ''
div!= excerpt
else
......
......@@ -36,13 +36,13 @@ mixin postHeader(post)
span= wordcount(post.content)
if theme.post_meta.reading_time.enable
- let postReadingTime = theme.post_meta.reading_time
- var postReadingTime = theme.post_meta.reading_time
span.post-meta-reading-time
i(class=`fa fa-${postReadingTime.icon}`)
if !theme.post_meta.icon_only
span= _p("post.reading_time") + " "
- let READING_TIME_UNIT = "m";
- var READING_TIME_UNIT = "m";
span= min2read(post.content, {cn: postReadingTime.speed.zh, en: postReadingTime.speed.en}) + READING_TIME_UNIT
if theme.valine && theme.valine.enable && theme.valine.visitor
......
mixin articleSort(posts)
section.article-sort
- let year, tmpYear
- var year, tmpYear
- posts.each(function (post) {
if post.date
- tmpYear = full_date(post.date, "YYYY")
......
......@@ -11,9 +11,9 @@ if theme.cdn && theme.cdn.js
script(src=url_for(url))
if theme.canvas_ribbon && theme.canvas_ribbon.enable
- let ribbon = theme.canvas_ribbon;
- var ribbon = theme.canvas_ribbon;
script(src=theme.cdn.canvas_ribbon size=ribbon.size alpha=ribbon.alpha zIndex=ribbon.zIndex)
if theme.canvas_nest && theme.canvas_nest.enable
- let nest = theme.canvas_nest;
- var nest = theme.canvas_nest;
script(src=theme.cdn.canvas_nest color=nest.color pointColor=nest.pointColor opacity=nest.opacity count=nest.count zIndex=nest.zIndex)
script.
let disqus_config = function () {
var disqus_config = function () {
this.page.url = '!{ page.permalink }';
this.page.identifier = '!{ page.path }';
this.page.title = '!{ page.title }';
};
(function() {
let d = document, s = d.createElement('script');
var d = document, s = d.createElement('script');
s.src = 'https://!{ theme.disqus.shortname }.disqus.com/embed.js';
s.setAttribute('data-timestamp', '' + +new Date());
(d.head || d.body).appendChild(s);
......
......@@ -3,12 +3,12 @@ script(src="https://cdn.jsdelivr.net/npm/gitalk@latest/dist/gitalk.min.js")
script(src="https://cdn.jsdelivr.net/npm/js-md5@latest/src/md5.min.js")
-
let lang = _.get(theme, 'gitalk.language')
var lang = _.get(theme, 'gitalk.language')
? theme.gitalk.language : config.language;
script.
window.onload = function() {
let gitalk = new Gitalk({
var gitalk = new Gitalk({
id: md5('!{ page.path }'),
clientID: '!{ theme.gitalk.client_id }',
clientSecret: '!{ theme.gitalk.client_secret }',
......
......@@ -4,7 +4,7 @@ script(src="https://cdn.jsdelivr.net/npm/js-md5@latest/src/md5.min.js")
script.
function renderGitment() {
let gitment = new Gitment({
var gitment = new Gitment({
id: md5('!{ page.path }'),
owner: "!{ theme.gitment.owner }",
repo: "!{ theme.gitment.repo }",
......
script.
window.onload = function() {
(function(d, s) {
let j, e = d.getElementsByTagName(s)[0];
var j, e = d.getElementsByTagName(s)[0];
if (typeof LivereTower === 'function') { return; }
j = d.createElement(s);
......
......@@ -3,8 +3,8 @@ script(src='https://cdn.jsdelivr.net/npm/valine@latest/dist/Valine.min.js')
script.
window.onload = function() {
let GUEST_INFO = ['nick', 'mail', 'link'];
let guest_info = '!{ theme.valine.meta }';
var GUEST_INFO = ['nick', 'mail', 'link'];
var guest_info = '!{ theme.valine.meta }';
guest_info = guest_info.split(',').filter(function(item) {
return GUEST_INFO.indexOf(item) > -1;
......
......@@ -5,10 +5,10 @@ block content
div.tag-cloud.main-content-layout
div.tag-cloud-title= _p("page.tags") + " - "
span.tag-cloud-num= site.tags.length
- let min_font = theme.tag_cloud ? theme.tag_cloud.min_size : 14
- let max_font = theme.tag_cloud ? theme.tag_cloud.max_size : 20
- let start_color = theme.tag_cloud ? theme.tag_cloud.start_color : "#a4d8fa"
- let end_color = theme.tag_cloud ? theme.tag_cloud.end_color : "#1b9ef3"
- var min_font = theme.tag_cloud ? theme.tag_cloud.min_size : 14
- var max_font = theme.tag_cloud ? theme.tag_cloud.max_size : 20
- var start_color = theme.tag_cloud ? theme.tag_cloud.start_color : "#a4d8fa"
- var end_color = theme.tag_cloud ? theme.tag_cloud.end_color : "#1b9ef3"
div.tag-cloud-item!= tagcloud({min_font: min_font, max_font: max_font, amount: theme.tag_cloud.max_amount, color: true, start_color, end_color})
else if (page.title === "categories")
div.category.main-content
......
......@@ -68,17 +68,15 @@ $(document).ready(function () {
item: function (data) {
var link = data.permalink ? data.permalink : CONFIG.root + data.path;
return (
'<a href="' +
link +
'" class="algolia-hit-item-link">' +
data._highlightResult.title.value +
'<a href="' + link + '" class="algolia-hit-item-link">' +
data._highlightResult.title.value +
'</a>'
);
},
empty: function (data) {
return (
'<div id="algolia-hits-empty">' +
algolia.languages.hits_empty.replace(/\$\{query}/, data.query) +
algolia.languages.hits_empty.replace(/\$\{query}/, data.query) +
'</div>'
);
}
......@@ -102,9 +100,8 @@ $(document).ready(function () {
return (
stats +
'<span class="algolia-logo pull-right">' +
' <img src="' +
CONFIG.root +
'images/algolia.svg" alt="Algolia" />' +
'<img src="' + CONFIG.root +
'images/algolia.svg" alt="Algolia" />' +
'</span>'
);
}
......
......@@ -7,26 +7,24 @@ $(document).ready(function test () {
var lang = item
.getAttribute('class')
.split(/\s/)
.filter(e => e !== CODEBLOCK_CLASS_NAME);
var codeHeader = $(`
<figcaption class="custom">
<span>${lang}</span>
</figcaption>
`)[0];
.filter(function (e) { return e !== CODEBLOCK_CLASS_NAME});
var codeHeader = $(
'<figcaption class="custom">' +
'<span>' + lang + '</span>' +
'</figcaption>'
)[0];
item.insertBefore(codeHeader, $(item).children().first()[0]);
}
});
var $copyIcon = $(`
<div class="copy-button">
<i class="fa fa-clipboard"></i>
</div>
`);
var COPY_BUTTON_WRAPPER = `
figure.highlight figcaption,
.post-footer-copyright
`;
var $copyIcon = $(
'<div class="copy-button">' +
'<i class="fa fa-clipboard"></i>' +
'</div>'
);
var COPY_BUTTON_WRAPPER =
'figure.highlight figcaption, .post-footer-copyright';
// Add a copy button to the selected elements.
$(COPY_BUTTON_WRAPPER).append($copyIcon);
......
......@@ -81,7 +81,7 @@ $(document).ready(function () {
});
if (currHeading !== lastHeading) {
var targetLink = $(`.sidebar-toc a[href="#${currHeading}"]`);
var targetLink = $('.sidebar-toc a[href="#' + currHeading + '"]');
// If the relevant "<a>" is not found, remain the state of the toc,
// either, remove styles for all active states.
......
......@@ -78,14 +78,14 @@ Stun.utils = Stun.$u = {
};
if (!$('.stun-alert')[0]) {
var $alert = $(`
<div class="stun-message">
<div class="stun-alert stun-alert-${status}">
<i class="stun-alert-icon fa fa-${icon[status]}"></i>
<span class="stun-alert-description">${text}</span>
</div>
</div>
`);
var $alert = $(
'<div class="stun-message">' +
'<div class="stun-alert stun-alert-' + status + '">' +
'<i class="stun-alert-icon fa fa-' + icon[status] + '"></i>' +
'<span class="stun-alert-description">' + text + '</span>' +
'</div>' +
'</div>'
);
$('body').append($alert);
}
......@@ -167,8 +167,11 @@ Stun.utils = Stun.$u = {
addIconToExternalLink: function (selector) {
if (!$(selector)[0]) return;
var $icon = $(`<i class="external-link fa fa-${
CONFIG.external_link.icon_name}"></i>`);
var $icon = $(
'<i class="external-link fa fa-' +
CONFIG.external_link.icon_name +
'"></i>'
);
$(selector).find('a[target="_blank"]').append($icon);
},
// Back the page to top.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册