diff --git a/bin/build-apidoc.sh b/bin/build-apidoc.sh index 8c0d062a2..f4ef609ba 100755 --- a/bin/build-apidoc.sh +++ b/bin/build-apidoc.sh @@ -15,7 +15,7 @@ for file in $(find docs/source/api -name "*.md"); do -e '1 s//\>/g' \ -e '1 s/\*//g' \ - -e '1 s/^# \(.*\)/---\ntitle: "\1"\n---/' \ + -e '1 s/^# \(.*\)/---\ntitle: "\1"\nauto: true\n---/' \ $file target=${file/\/_/\/} if [ "$file" != "$target" ]; then diff --git a/bin/build-docs.sh b/bin/build-docs.sh index e78ad98d4..04bca683c 100755 --- a/bin/build-docs.sh +++ b/bin/build-docs.sh @@ -9,9 +9,9 @@ npm run build cp CNAME public/ cp ../CHANGELOG.md source/tutorials/changelog.md -sed -i '1i ---\ntitle: Changelog\n---\n' source/tutorials/changelog.md +sed -i '1i ---\ntitle: Changelog\nauto: true\n---\n' source/tutorials/changelog.md cp ../CHANGELOG.md source/zh-cn/tutorials/changelog.md -sed -i '1i ---\ntitle: 更新日志\n---\n' source/zh-cn/tutorials/changelog.md +sed -i '1i ---\ntitle: 更新日志\nauto: true\n---\n' source/zh-cn/tutorials/changelog.md if [ "$HEXO_ALGOLIA_INDEXING_KEY" != "" ]; then npm run index diff --git a/docs/_config.yml b/docs/_config.yml index 3da6b0313..12c57eed5 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -5,7 +5,7 @@ author: Harttle language: en timezone: UTC -url: https://harttle.land/liquidjs +url: https://liquidjs.com root: / permalink: news/:year/:month/:day/:title/ archive_dir: news diff --git a/docs/package-lock.json b/docs/package-lock.json index b33acdfab..ea8ca12ea 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -1612,8 +1612,9 @@ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" }, "hexo": { - "version": "github:hexojs/hexo#6437ff51869faf1add5cbb1f5411586b61a93fbf", - "from": "github:hexojs/hexo", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/hexo/-/hexo-4.2.0.tgz", + "integrity": "sha512-j2Kzgx/eWF0IgSfUEsAAhr0mDaaqR3E1MTus0/Vrs+JpQdMiSlqSbudPf2S9O4FHi5CAzDCuzToGlg2kgoQxcA==", "requires": { "abbrev": "^1.1.1", "archy": "^1.0.0", @@ -1624,7 +1625,7 @@ "hexo-fs": "^2.0.0", "hexo-i18n": "^1.0.0", "hexo-log": "^1.0.0", - "hexo-util": "^1.9.0", + "hexo-util": "^1.8.0", "js-yaml": "^3.12.0", "lodash": "^4.17.11", "micromatch": "^4.0.2", @@ -1634,12 +1635,13 @@ "pretty-hrtime": "^1.0.3", "resolve": "^1.8.1", "strip-ansi": "^6.0.0", + "strip-indent": "^3.0.0", "swig-extras": "0.0.1", "swig-templates": "^2.0.3", "text-table": "^0.2.0", "tildify": "^2.0.0", "titlecase": "^1.1.2", - "warehouse": "^3.0.2" + "warehouse": "^3.0.1" }, "dependencies": { "ansi-styles": { diff --git a/docs/package.json b/docs/package.json index 90783d677..49f0774d2 100644 --- a/docs/package.json +++ b/docs/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "cheerio": "^0.22.0", - "hexo": "hexojs/hexo", + "hexo": "^4.2.0", "hexo-algolia": "^1.3.1", "hexo-clean-css": "^1.0.0", "hexo-filter-nofollow": "^2.0.2", diff --git a/docs/scripts/helpers.js b/docs/scripts/helpers.js index 560fab0fb..95f82c523 100644 --- a/docs/scripts/helpers.js +++ b/docs/scripts/helpers.js @@ -1,146 +1,143 @@ /* global hexo */ -'use strict'; +'use strict' -const { resolve, basename } = require('path'); -const { readFileSync } = require('fs'); -const cheerio = require('cheerio'); -const lunr = require('lunr'); -const full_url_for = hexo.extend.helper.get('full_url_for').bind(hexo); +const { resolve, basename } = require('path') +const { readFileSync } = require('fs') +const cheerio = require('cheerio') +const fullUrlFor = hexo.extend.helper.get('full_url_for').bind(hexo) -const localizedPath = ['tutorials', 'filters', 'tags', 'playground', 'api']; +const localizedPath = ['tutorials', 'filters', 'tags', 'playground', 'api'] -hexo.extend.helper.register('page_nav', function() { - const type = this.page.canonical_path.split('/')[0]; - const sidebar = this.site.data.sidebar[type]; - const path = basename(this.path); - const list = {}; - const prefix = 'sidebar.' + type + '.'; +hexo.extend.helper.register('page_nav', function () { + const type = this.page.canonical_path.split('/')[0] + const sidebar = this.site.data.sidebar[type] + const path = basename(this.path) + const list = {} + const prefix = 'sidebar.' + type + '.' for (const i in sidebar) { - if (typeof sidebar[i] === 'string') list[sidebar[i]] = i; - else for (const j in sidebar[i]) list[sidebar[i][j]] = j; + if (typeof sidebar[i] === 'string') list[sidebar[i]] = i + else for (const j in sidebar[i]) list[sidebar[i][j]] = j } - const keys = Object.keys(list); - const index = keys.indexOf(path); - let result = ''; + const keys = Object.keys(list) + const index = keys.indexOf(path) + let result = '' if (index > 0) { - result += `${this.__('page.prev')}`; + result += `${this.__('page.prev')}` } if (index < keys.length - 1) { - result += `${this.__('page.next')}`; + result += `${this.__('page.next')}` } - return result; -}); + return result +}) -hexo.extend.helper.register('raw', function(filepath) { - const content = readFileSync(resolve(this.view_dir, filepath)); - return content; -}); +hexo.extend.helper.register('raw', function (filepath) { + const content = readFileSync(resolve(this.view_dir, filepath)) + return content +}) -hexo.extend.helper.register('doc_sidebar', function(className) { - const type = this.page.canonical_path.split('/')[0]; - const sidebar = this.site.data.sidebar[type]; - const path = basename(this.path); - let result = ''; - const self = this; - const prefix = 'sidebar.' + type + '.'; +hexo.extend.helper.register('doc_sidebar', function (className) { + const type = this.page.canonical_path.split('/')[0] + const sidebar = this.site.data.sidebar[type] + const path = basename(this.path) + let result = '' + const { __ } = this + const prefix = 'sidebar.' + type + '.' if (typeof sidebar === 'undefined') { - return ''; + return '' } for (const [title, menu] of Object.entries(sidebar)) { - if (typeof menu === 'string') renderLink(title, menu); - else renderSection(title, menu); + if (typeof menu === 'string') renderLink(title, menu) + else renderSection(title, menu) } - return result; + return result - function renderLink(text, link) { - let itemClass = className + '-link'; - if (link === path) itemClass += ' current'; + function renderLink (text, link) { + let itemClass = className + '-link' + if (link === path) itemClass += ' current' - const localized = self.__(prefix + text) === prefix + text ? text : self.__(prefix + text); - result += '' + localized + ''; + const localized = __(prefix + text) === prefix + text ? text : __(prefix + text) + result += '' + localized + '' } - function renderSection(title, menu) { - result += '' + self.__(prefix + title) + ''; - for (const [text, link] of Object.entries(menu)) renderLink(text, link); + function renderSection (title, menu) { + result += '' + __(prefix + title) + '' + for (const [text, link] of Object.entries(menu)) renderLink(text, link) } -}); +}) -hexo.extend.helper.register('header_menu', function(className) { - const menu = this.site.data.menu; - let result = ''; - const self = this; - const lang = this.page.lang; - const isEnglish = lang === 'en'; +hexo.extend.helper.register('header_menu', function (className) { + const menu = this.site.data.menu + let result = '' + const lang = this.page.lang + const isEnglish = lang === 'en' for (const [title, path] of Object.entries(menu)) { - let langPath = path; - if (!isEnglish && ~localizedPath.indexOf(title)) langPath = lang + path; - const url = self.url_for(langPath); - const active = ('/' + this.page.canonical_path).slice(0, path.length) === path ? ' active' : ''; - result += `${self.__('menu.' + title)}`; + let langPath = path + if (!isEnglish && ~localizedPath.indexOf(title)) langPath = lang + path + const url = this.url_for(langPath) + const active = ('/' + this.page.canonical_path).slice(0, path.length) === path ? ' active' : '' + result += `${this.__('menu.' + title)}` } - return result; -}); + return result +}) -hexo.extend.helper.register('canonical_url', function(lang) { - let path = this.page.path; - if (lang && lang !== 'en') path = lang + '/' + path; +hexo.extend.helper.register('canonical_url', function (lang) { + let path = this.page.path + if (lang && lang !== 'en') path = lang + '/' + path - return full_url_for(path); -}); + return fullUrlFor(path) +}) -hexo.extend.helper.register('url_for_lang', function(path) { - const lang = this.page.lang; - let url = this.url_for(path); +hexo.extend.helper.register('url_for_lang', function (path) { + const lang = this.page.lang + let url = this.url_for(path) - if (lang !== 'en' && path[0] === '/') url = '/' + lang + path; + if (lang !== 'en' && path[0] === '/') url = '/' + lang + path - return url; -}); + return url +}) -hexo.extend.helper.register('raw_link', path => `https://github.com/hexojs/site/edit/master/source/${path}`); +hexo.extend.helper.register('raw_link', path => `https://github.com/harttle/liquidjs/edit/master/docs/source/${path}`) hexo.extend.helper.register('page_anchor', str => { - const $ = cheerio.load(str, {decodeEntities: false}); - const headings = $('h1, h2, h3, h4, h5, h6'); + const $ = cheerio.load(str, { decodeEntities: false }) + const headings = $('h1, h2, h3, h4, h5, h6') - if (!headings.length) return str; + if (!headings.length) return str - headings.each(function() { - const id = $(this).attr('id'); + headings.each(function () { + const id = $(this).attr('id') $(this) .addClass('article-heading') - .append(``); - }); + .append(``) + }) - return $.html(); -}); + return $.html() +}) -// Will be replace with full_url_for after hexo v4 release -hexo.extend.helper.register('canonical_path_for_nav', function() { - const path = this.page.canonical_path; - for (const slug of localizedPath) if (path.startsWith(slug)) return path; - return ''; -}); +// Will be replace with fullUrlFor after hexo v4 release +hexo.extend.helper.register('canonical_path_for_nav', function () { + const path = this.page.canonical_path + for (const slug of localizedPath) if (path.startsWith(slug)) return path + return '' +}) -hexo.extend.helper.register('lang_name', function(lang) { - const data = this.site.data.languages[lang]; - return data.name || data; -}); - -hexo.extend.helper.register('hexo_version', function() { - return this.env.version; -}); +hexo.extend.helper.register('lang_name', function (lang) { + const data = this.site.data.languages[lang] + return data.name || data +}) +hexo.extend.helper.register('hexo_version', function () { + return this.env.version +}) diff --git a/docs/scripts/tags.js b/docs/scripts/tags.js index 3777442ef..c1abc1fcb 100644 --- a/docs/scripts/tags.js +++ b/docs/scripts/tags.js @@ -1,19 +1,19 @@ /* global hexo */ -'use strict'; +'use strict' hexo.extend.tag.register('note', (args, content) => { - const className = args.shift(); - let header = ''; - let result = ''; + const className = args.shift() + let header = '' + let result = '' if (args.length) { - header += `${args.join(' ')}`; + header += `${args.join(' ')}` } - result += `
${header}`; - result += hexo.render.renderSync({text: content, engine: 'markdown'}); - result += '
'; + result += `
${header}` + result += hexo.render.renderSync({ text: content, engine: 'markdown' }) + result += '
' - return result; -}, true); + return result +}, true) diff --git a/docs/source/sw.js b/docs/source/sw.js index a98469b2b..5e9f49c78 100644 --- a/docs/source/sw.js +++ b/docs/source/sw.js @@ -1,59 +1,58 @@ -/* globals self, caches, fetch */ -'use strict'; +'use strict' -const CACHE_NAME = '{{site.time}}'; +const CACHE_NAME = '{{site.time}}' const urlsToCache = [ '/', '/css/navy.css', '/js/main.js', '/icon/logo.png', '/fonts/icomoon.ttf?e8nnma' -]; +] const blackList = [ /google-analytics.com.*collect/ -]; +] self.addEventListener('install', event => { - event.waitUntil(caches.open(CACHE_NAME).then(cache => cache.addAll(urlsToCache))); -}); + event.waitUntil(caches.open(CACHE_NAME).then(cache => cache.addAll(urlsToCache))) +}) self.addEventListener('activate', event => { event.waitUntil(caches.keys().then(cacheNames => Promise.all( cacheNames.map(cacheName => cacheName !== CACHE_NAME && caches.delete(cacheName)) - ))); -}); + ))) +}) self.addEventListener('fetch', event => { if ( event.request.cache === 'only-if-cached' && event.request.mode !== 'same-origin' - ) return cache(event.request); + ) return cache(event.request) if ( event.request.method !== 'GET' || blackList.some(regex => regex.exec(event.request.url)) - ) return network(event.request); - const pn = networkAndSave(event.request); - event.respondWith(cache(event.request).then(res => res || pn).catch(() => pn)); -}); + ) return network(event.request) + const pn = networkAndSave(event.request) + event.respondWith(cache(event.request).then(res => res || pn).catch(() => pn)) +}) -function cache(req) { - return caches.open(CACHE_NAME).then(cache => cache.match(req.clone())); +function cache (req) { + return caches.open(CACHE_NAME).then(cache => cache.match(req.clone())) } -function networkAndSave(req) { +function networkAndSave (req) { return network(req).then(res => { - if (validate(res)) save(req.clone(), res.clone()); - return res; - }); + if (validate(res)) save(req.clone(), res.clone()) + return res + }) } -function network(req) { - return fetch(req.clone()); +function network (req) { + return fetch(req.clone()) } -function save(key, val) { - return caches.open(CACHE_NAME).then(cache => cache.put(key, val)); +function save (key, val) { + return caches.open(CACHE_NAME).then(cache => cache.put(key, val)) } -function validate(res) { - if (res && res.type === 'basic' && res.status !== 200) return false; - return true; +function validate (res) { + if (res && res.type === 'basic' && res.status !== 200) return false + return true } diff --git a/docs/themes/navy/languages/en.yml b/docs/themes/navy/languages/en.yml index 9c0775708..520a5a005 100644 --- a/docs/themes/navy/languages/en.yml +++ b/docs/themes/navy/languages/en.yml @@ -23,6 +23,7 @@ page: contents: Contents back_to_top: Back to Top improve: Improve this doc + report: Report problems prev: Prev next: Next last_updated: "Last updated: %s" diff --git a/docs/themes/navy/languages/zh-cn.yml b/docs/themes/navy/languages/zh-cn.yml index 991e3e263..7f7f0cfc1 100644 --- a/docs/themes/navy/languages/zh-cn.yml +++ b/docs/themes/navy/languages/zh-cn.yml @@ -22,7 +22,8 @@ playground: page: contents: 目录 back_to_top: 回到顶部 - improve: 改进本文 + improve: 改进这篇文档 + report: 报告问题 prev: 上一页 next: 下一页 last_updated: 上次更新:%s diff --git a/docs/themes/navy/layout/page.swig b/docs/themes/navy/layout/page.swig index c531783da..669a740bc 100644 --- a/docs/themes/navy/layout/page.swig +++ b/docs/themes/navy/layout/page.swig @@ -8,7 +8,11 @@

{{ page.title }}

+ {% if page.auto %} + + {% else %} + {% endif %}
{{ page_anchor(page.content) }} diff --git a/docs/themes/navy/source/css/_partial/icomoon.css b/docs/themes/navy/source/css/_partial/icomoon.css index 4df37049f..960638a48 100644 --- a/docs/themes/navy/source/css/_partial/icomoon.css +++ b/docs/themes/navy/source/css/_partial/icomoon.css @@ -70,3 +70,6 @@ i { .icon-typescript:before { content: "\e900"; } +.icon-chat-bubble-dots:before { + content: "\e901"; +} diff --git a/docs/themes/navy/source/css/_partial/playground.styl b/docs/themes/navy/source/css/_partial/playground.styl index 4c5a73d82..cc9bf468b 100644 --- a/docs/themes/navy/source/css/_partial/playground.styl +++ b/docs/themes/navy/source/css/_partial/playground.styl @@ -24,5 +24,3 @@ #editorEl, #previewEl font-size: 1em - .ace_scroller, .ace_gutter - padding: 15px 0px; diff --git a/docs/themes/navy/source/fonts/icomoon.eot b/docs/themes/navy/source/fonts/icomoon.eot index 1d79414ef..04bc4dd09 100644 Binary files a/docs/themes/navy/source/fonts/icomoon.eot and b/docs/themes/navy/source/fonts/icomoon.eot differ diff --git a/docs/themes/navy/source/fonts/icomoon.svg b/docs/themes/navy/source/fonts/icomoon.svg index 7b1bd4351..a4d46b5d2 100644 --- a/docs/themes/navy/source/fonts/icomoon.svg +++ b/docs/themes/navy/source/fonts/icomoon.svg @@ -8,6 +8,7 @@ + @@ -22,4 +23,5 @@ + \ No newline at end of file diff --git a/docs/themes/navy/source/fonts/icomoon.ttf b/docs/themes/navy/source/fonts/icomoon.ttf index 7ed8d3585..d0c03f0ce 100644 Binary files a/docs/themes/navy/source/fonts/icomoon.ttf and b/docs/themes/navy/source/fonts/icomoon.ttf differ diff --git a/docs/themes/navy/source/fonts/icomoon.woff b/docs/themes/navy/source/fonts/icomoon.woff index 61b32bfec..5513537b7 100644 Binary files a/docs/themes/navy/source/fonts/icomoon.woff and b/docs/themes/navy/source/fonts/icomoon.woff differ diff --git a/docs/themes/navy/source/js/main.js b/docs/themes/navy/source/js/main.js index 90abc9a81..30643c110 100644 --- a/docs/themes/navy/source/js/main.js +++ b/docs/themes/navy/source/js/main.js @@ -79,6 +79,7 @@ tabSize: 2, useSoftTabs: true }); + editor.renderer.setScrollMargin(15); return editor; }