hexo-theme-next
Advanced tools
Comparing version 8.0.0-rc.5 to 8.0.0
@@ -50,2 +50,8 @@ <div align="right"> | ||
After the installation, open Hexo config file and set `theme` variable to `next`. | ||
```yml | ||
theme: next | ||
``` | ||
## Configuration | ||
@@ -61,3 +67,3 @@ | ||
Plugins extend and expand the functionality of NexT. There are two types of plugins: core plugins and third-party plugins. The core plugins are required by the basic functions of NexT. Third-party plugins are loaded from jsDelivr CDN by default, and they provide a large number of optional features. | ||
Plugins extend and expand the functionality of NexT. There are two types of plugins: core plugins and third-party plugins. The core plugins are required by the basic functions of NexT. Third-party plugins provide a large number of optional features. | ||
@@ -74,5 +80,5 @@ Configuring these plugins is very easy. Например, Вы хотите использовать `pjax` для своего сайта. Открываем конфиг NexT'а и находим: | ||
If you want to specify the CDN provider for any plugins, you need to set / update the CDN URL. | ||
Third-party plugins are loaded from [jsDelivr](https://www.jsdelivr.com) CDN by default. We also provide other optional CDNs, including the famous [UNPKG](https://unpkg.com) and [CDNJS](https://cdnjs.com). | ||
For example, if you want to set the CDN URL for `mediumzoom`, go to NexT config and see: | ||
For example, if you want to use `unpkg` instead of `jsdelivr` as the default CDN provider, you need to edit the following settings in NexT config file: | ||
@@ -84,3 +90,3 @@ ```yml | ||
# ... | ||
mediumzoom: # Set or update mediumzoom CDN URL. | ||
plugins: unpkg | ||
``` | ||
@@ -87,0 +93,0 @@ |
@@ -52,13 +52,6 @@ <div align="right"> | ||
反馈 Bug 前,请再次确认您已经查看了 [你需要了解的](#你需要了解的) 内容,避免提交重复的 Issue。确定相关仓库后,创建 Issue 并按照 [模板](../../.github/ISSUE_TEMPLATE.md) 尽可能的详细填写相关信息。 | ||
反馈 Bug 前,请再次确认您已经查看了 [你需要了解的](#你需要了解的) 内容,避免提交重复的 Issue。创建 Issue 时,请认真遵守如下指南,这样我们才能更好地理解问题,重现问题和解决问题。 | ||
请认真遵守如下指南,这样我们才能更好地理解问题,重现问题和解决问题。 | ||
* 在标题中清晰准确地描述你的问题。 | ||
* 参照如下问题尽可能多的提供信息: | ||
* Bug 是否能够重现?是一直出现还是偶尔出现? | ||
* Bug 是从什么时候开始发生的? | ||
* 如果 Bug 突然发生,使用 [旧版本主题](https://github.com/next-theme/hexo-theme-next/releases) 是否能够重现 Bug?又是从哪个版本开始出现 Bug? | ||
* 你所使用 Node,Hexo 以及 NexT 的版本号多少?你可以运行 `node -v` 和 `hexo version` 获取版本号,或者查看文件 `package.json` 的内容。 | ||
* 你使用了哪些插件包?查看文件 `package.json` 的内容即可获取。 | ||
* 按照 [模板](../../.github/ISSUE_TEMPLATE.md) 尽可能的详细填写相关信息。 | ||
* 一步步详细你是如何重现 Bug 的,做了什么,使用了哪些功能等等。如果你需要展示代码段,请使用 [Markdown 代码块](https://help.github.com/articles/creating-and-highlighting-code-blocks/) 或 [Github 预览链接](https://help.github.com/articles/creating-a-permanent-link-to-a-code-snippet/) 或 [Gist 链接](https://gist.github.com/)。 | ||
@@ -105,3 +98,3 @@ * 提供 Bug 的样例,如图像文件、在线演示网址等等。 | ||
- 标题为版本号。 | ||
- 所有内容更改的类型包括了 **Breaking Changes**, **Updates**, **Features** 和 **Bug Fixes**。在描述 Breaking Changes 时,使用二级标题分别陈述,描述其他类型时,使用项目列表陈述。 | ||
- 内容根据 [Release Drafter](https://github.com/release-drafter/release-drafter) 的模版填写。 | ||
- 使用被动语态,省略主语。 | ||
@@ -124,3 +117,3 @@ - 所有的变化都需要记录在版本说明中。对于没有使用 PR 的更改,需要添加相应的 commit 编号。如果使用了 PR 进行合并修改,则直接添加相应的 PR 编号即可。 | ||
为了方便维护人员和用户能够快速找到他们想要查看的问题,我们使用“标签”功能对 Pull requests 和 Issues 进行分类。 | ||
为了方便维护人员和用户能够快速找到他们想要查看的问题,我们使用「标签」功能对 Pull requests 和 Issues 进行分类。 | ||
@@ -140,9 +133,10 @@ 如果您不确定某个标签的含义,或者不知道将哪些标签应用于 PR 或 issue,千万别错过这个。 | ||
- `Duplicate`: 重复提及的 Issue | ||
- `Irrelevant`: 与 NexT 主题无关的 Issue | ||
- `Hexo`: 与 Hexo 相关的 Issue | ||
- `Hexo Plugin`: 与 Hexo 插件相关的 Issue | ||
- `Browser`: 与浏览器相关的 Issue | ||
- `Invalid`: 无法复现的 Issue | ||
- `Expected Behavior`: 与预期行为相符的 Issue | ||
- `Need More Info`: 需要更多信息的 Issue | ||
- `Verified`: 已经被确认的 Issue | ||
- `Solved`: 已经解决的 Issue | ||
- `Backlog`: 待解决的 Issue | ||
- `To Do`: 待解决的 Issue | ||
- `Stale`: 由于长期无人回应被封存的 Issue | ||
@@ -157,3 +151,2 @@ | ||
- `i18n`: 更新了翻译的 Pull Request | ||
- `Work in Progress`: 仍在进行改动和完善的 Pull Request | ||
- `Skip Release`: 无需在 Release Note 中展现的 Pull Request | ||
@@ -168,4 +161,3 @@ | ||
- `Performance`: 提出性能问题的 Issue 或者提高了 NexT 主题性能的 Pull Request | ||
- `Hexo`: 与 Hexo 和 Hexo 插件相关的 Issue 或者 Pull Request | ||
- `Template Engine`: 与模版引擎相关的 Issue 或者 Pull Request | ||
- `Layout`: 与模版引擎相关的 Issue 或者 Pull Request | ||
- `CSS`: 与 NexT 主题 CSS 文件相关的 Issue 或者 Pull Request | ||
@@ -193,4 +185,4 @@ - `Fonts`: 与 NexT 主题字体相关的 Issue 或者 Pull Request | ||
* `Release`:版本发布 | ||
- `subject` 用于简要描述修改变更的内容,如 `Update code highlighting in readme.md`。 | ||
- `subject` 用于简要描述修改变更的内容,如 `Update code highlighting in README.md`。 | ||
* 句尾不要使用符号。 | ||
* 使用现在时、祈使句语气。 |
@@ -50,2 +50,8 @@ <div align="right"> | ||
安装完成后,在 Hexo 配置文件中将 `theme` 设置为 `next`。 | ||
```yml | ||
theme: next | ||
``` | ||
## 配置 | ||
@@ -61,3 +67,3 @@ | ||
插件丰富和拓展了 NexT 的功能。这些插件分为两种:核心插件和第三方插件。核心插件被 NexT 的基础功能所依赖。第三方插件默认通过 jsDelivr 的 CDN 服务加载,它们提供了大量的可选功能。 | ||
插件丰富和拓展了 NexT 的功能。这些插件分为两种:核心插件和第三方插件。核心插件被 NexT 的基础功能所依赖。第三方插件提供了大量的可选功能。 | ||
@@ -74,5 +80,5 @@ 配置这些插件非常简单。例如,你想要在你的站点中使用 `pjax` 插件,请进入 NexT 配置文件,启用 `pjax` 配置项: | ||
如果你想要通过自定义 CDN 而不是默认的 jsDelivr 来加载插件脚本,那么需要设置相关的 CDN 链接。 | ||
第三方插件默认通过 [jsDelivr](https://www.jsdelivr.com) CDN 服务加载。我们也提供了其它的 CDN 服务供选择,包括著名的 [UNPKG](https://unpkg.com) 和 [CDNJS](https://cdnjs.com)。 | ||
例如,你想要为 `mediumzoom` 插件设置 CDN 地址,进入 NexT 配置文件并找到如下内容: | ||
例如,你想要使用 `unpkg` 代替 `jsdelivr` 作为默认的 CDN 提供商,你需要在 NexT 配置文件中进行如下设置: | ||
@@ -84,3 +90,3 @@ ```yml | ||
# ... | ||
mediumzoom: # Set or update mediumzoom CDN URL. | ||
plugins: unpkg | ||
``` | ||
@@ -87,0 +93,0 @@ |
@@ -7,7 +7,7 @@ # Internationalization (i18n) | ||
```yaml | ||
```yml | ||
language: en | ||
``` | ||
```yaml | ||
```yml | ||
language: | ||
@@ -25,3 +25,3 @@ - zh-CN | ||
```yaml | ||
```yml | ||
# language | ||
@@ -28,0 +28,0 @@ zh-CN: |
{ | ||
"name": "hexo-theme-next", | ||
"version": "8.0.0-rc.5", | ||
"version": "8.0.0", | ||
"description": "Elegant and powerful theme for Hexo.", | ||
@@ -27,10 +27,10 @@ "main": "package.json", | ||
"devDependencies": { | ||
"@next-theme/eslint-config": "0.0.1", | ||
"chai": "4.2.0", | ||
"eslint": "7.5.0", | ||
"eslint-config-theme-next": "1.2.1", | ||
"hexo": "5.0.0", | ||
"hexo-renderer-marked": "3.0.0", | ||
"eslint": "7.7.0", | ||
"hexo": "5.1.1", | ||
"hexo-renderer-marked": "3.1.0", | ||
"husky": "4.2.5", | ||
"js-yaml": "3.14.0", | ||
"mocha": "8.1.0", | ||
"mocha": "8.1.3", | ||
"stylint": "2.0.0" | ||
@@ -37,0 +37,0 @@ }, |
@@ -50,2 +50,8 @@ <div align="right"> | ||
After the installation, open Hexo config file and set `theme` variable to `next`. | ||
```yml | ||
theme: next | ||
``` | ||
## Configuration | ||
@@ -61,3 +67,3 @@ | ||
Plugins extend and expand the functionality of NexT. There are two types of plugins: core plugins and third-party plugins. The core plugins are required by the basic functions of NexT. Third-party plugins are loaded from jsDelivr CDN by default, and they provide a large number of optional features. | ||
Plugins extend and expand the functionality of NexT. There are two types of plugins: core plugins and third-party plugins. The core plugins are required by the basic functions of NexT. Third-party plugins provide a large number of optional features. | ||
@@ -74,5 +80,5 @@ Configuring these plugins is very easy. For example, if you want to enable `pjax` on your site, just set `pjax` to `true` in NexT config file: | ||
If you want to specify the CDN provider for any plugins, you need to set / update the CDN URL. | ||
Third-party plugins are loaded from [jsDelivr](https://www.jsdelivr.com) CDN by default. We also provide other optional CDNs, including the famous [UNPKG](https://unpkg.com) and [CDNJS](https://cdnjs.com). | ||
For example, if you want to set the CDN URL for `mediumzoom`, go to NexT config and see: | ||
For example, if you want to use `unpkg` instead of `jsdelivr` as the default CDN provider, you need to edit the following settings in NexT config file: | ||
@@ -84,3 +90,3 @@ ```yml | ||
# ... | ||
mediumzoom: # Set or update mediumzoom CDN URL. | ||
plugins: unpkg | ||
``` | ||
@@ -87,0 +93,0 @@ |
@@ -6,4 +6,6 @@ /* global hexo */ | ||
hexo.extend.filter.register('before_generate', () => { | ||
// Merge config. | ||
// Merge config | ||
require('./lib/config')(hexo); | ||
// Set vendors | ||
require('./lib/vendors')(hexo); | ||
// Add filter type `theme_inject` | ||
@@ -10,0 +12,0 @@ require('./lib/injects')(hexo); |
'use strict'; | ||
const merge = require('hexo-util').deepMerge || require('lodash/merge'); | ||
let plugins; | ||
try { | ||
plugins = require('@next-theme/plugins'); | ||
} catch (error) { | ||
} | ||
@@ -22,17 +17,18 @@ module.exports = hexo => { | ||
const { cache, language_switcher } = hexo.theme.config; | ||
const { cache, language_switcher, leancloud_visitors, valine } = hexo.theme.config; | ||
const warning = function(...args) { | ||
hexo.log.warn(`Since ${args[0]} is turned on, the ${args[1]} is disabled to avoid potential hazards.`); | ||
}; | ||
if (cache && cache.enable && language_switcher) { | ||
hexo.log.warn('Since language_switcher is turned on, the caching is disabled to avoid potential hazards.'); | ||
warning('language_switcher', 'caching'); | ||
cache.enable = false; | ||
} | ||
if (cache && cache.enable && hexo.config.relative_link) { | ||
hexo.log.warn('Since caching is turned on, the `relative_link` option in Hexo `_config.yml` is set to `false` to avoid potential hazards.'); | ||
warning('caching', '`relative_link` option in Hexo `_config.yml`'); | ||
hexo.config.relative_link = false; | ||
} | ||
if (typeof plugins === 'function') { | ||
const { vendors, generator } = plugins(); | ||
Object.keys(vendors).forEach(key => { | ||
hexo.theme.config.vendors[key] = hexo.theme.config.vendors[key] || vendors[key]; | ||
}); | ||
hexo.extend.generator.register('next_vendors', () => generator); | ||
if (leancloud_visitors && leancloud_visitors.enable && valine && valine.enable && valine.visitor) { | ||
warning('valine.visitor', 'leancloud_visitors'); | ||
leancloud_visitors.enable = false; | ||
} | ||
@@ -39,0 +35,0 @@ hexo.config.meta_generator = false; |
'use strict'; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { resolve, highlightTheme } = require('./utils'); | ||
function resolve(name) { | ||
return path.dirname(require.resolve(`${name}/package.json`)); | ||
} | ||
function highlightTheme(name) { | ||
const file = `${resolve('highlight.js')}/styles/${name}.css`; | ||
const css = fs.readFileSync(file).toString(); | ||
let rule = ''; | ||
let background = ''; | ||
let foreground = ''; | ||
css.replace(/\.hljs(\s+|,[^{]+)\{(.*?)\}/sg, (match, $1, content) => { | ||
rule += content; | ||
return match; | ||
}); | ||
rule.split('\n').forEach(line => { | ||
if (line.includes('background:')) background = line.split('background:')[1]; | ||
else if (line.includes('background-color:')) background = line.split('background-color:')[1]; | ||
else if (line.includes('color:')) foreground = line.split('color:')[1]; | ||
}); | ||
return { | ||
file, | ||
background, | ||
foreground | ||
}; | ||
} | ||
function prismTheme(name) { | ||
let file = `${resolve('prismjs')}/themes/${name}.css`; | ||
if (!fs.existsSync(file)) file = `${resolve('prism-themes')}/themes/${name}.css`; | ||
let file = resolve('prismjs', `themes/${name}.css`); | ||
if (!fs.existsSync(file)) file = resolve('prism-themes', `themes/${name}.css`); | ||
return file; | ||
@@ -52,4 +26,4 @@ } | ||
dark : prismTheme(theme.codeblock.prism.dark), | ||
number: `${resolve('prismjs')}/plugins/line-numbers/prism-line-numbers.css` | ||
number: resolve('prismjs', 'plugins/line-numbers/prism-line-numbers.css') | ||
}; | ||
}; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
const path = require('path'); | ||
const points = require('./injects-point'); | ||
const { points } = require('./utils'); | ||
const defaultExtname = '.njk'; | ||
@@ -8,0 +8,0 @@ |
@@ -43,4 +43,4 @@ /* global hexo */ | ||
{% endif %} | ||
`, {}, {}, theme.changyan.post_meta_order); | ||
`, {}, {}); | ||
}); |
@@ -39,4 +39,4 @@ /* global hexo */ | ||
{% endif %} | ||
`, {}, {}, theme.disqus.post_meta_order); | ||
`, {}, {}); | ||
}); |
@@ -33,4 +33,4 @@ /* global hexo */ | ||
{% endif %} | ||
`, {}, {}, theme.valine.post_meta_order); | ||
`, {}, {}); | ||
}); |
@@ -5,3 +5,3 @@ /* global hexo */ | ||
const points = require('../events/lib/injects-point'); | ||
const { points } = require('../events/lib/utils'); | ||
@@ -8,0 +8,0 @@ hexo.extend.filter.register('theme_inject', injects => { |
@@ -8,7 +8,7 @@ /* global hexo */ | ||
hexo.extend.filter.register('template_locals', locals => { | ||
const { env, config } = hexo; | ||
const { version, config } = hexo; | ||
const { __, theme, page } = locals; | ||
const { i18n } = hexo.theme; | ||
// Hexo & NexT version | ||
locals.hexo_version = env.version; | ||
locals.hexo_version = version; | ||
locals.next_version = require('../../package.json').version; | ||
@@ -15,0 +15,0 @@ // Language & Config |
@@ -9,2 +9,6 @@ /* global hexo */ | ||
if (!hexo.locals.get('pages').some(page => page.type === 'schedule')) { | ||
hexo.route.remove('js/schedule.js'); | ||
} | ||
if (!theme.bookmark.enable) { | ||
@@ -16,18 +20,4 @@ hexo.route.remove('js/bookmark.js'); | ||
hexo.route.remove('js/motion.js'); | ||
hexo.route.remove('lib/animate-css/animate.min.css'); | ||
} else if (theme.vendors.animate_css) { | ||
hexo.route.remove('lib/animate-css/animate.min.css'); | ||
} | ||
if (theme.vendors.fontawesome) { | ||
const lists = hexo.route.list(); | ||
lists.forEach(path => { | ||
if (path.startsWith('lib/font-awesome')) hexo.route.remove(path); | ||
}); | ||
} | ||
if (theme.vendors.anime) { | ||
hexo.route.remove('lib/anime.min.js'); | ||
} | ||
if (!theme.algolia_search.enable) { | ||
@@ -34,0 +24,0 @@ hexo.route.remove('js/algolia-search.js'); |
@@ -18,15 +18,25 @@ /* global hexo */ | ||
hexo.extend.helper.register('next_js', function(url) { | ||
hexo.extend.helper.register('next_js', function(file, pjax = false) { | ||
const { next_version } = this; | ||
const { js } = this.theme; | ||
const { internal } = this.theme.vendors; | ||
let src = `${js}/${url}`; | ||
if (internal === 'jsdelivr') { | ||
src = `//cdn.jsdelivr.net/npm/hexo-theme-next@${next_version}/source/js/${url}`; | ||
} else if (internal === 'unpkg') { | ||
src = `//unpkg.com/hexo-theme-next@${next_version}/source/js/${url}`; | ||
} | ||
return this.js(src); | ||
const links = { | ||
local : this.url_for(`${this.theme.js}/${file}`), | ||
jsdelivr: `//cdn.jsdelivr.net/npm/hexo-theme-next@${next_version}/source/js/${file}`, | ||
unpkg : `//unpkg.com/hexo-theme-next@${next_version}/source/js/${file}` | ||
}; | ||
const src = links[internal] || links.local; | ||
return `<script ${pjax ? 'data-pjax ' : ''}src="${src}"></script>`; | ||
}); | ||
hexo.extend.helper.register('post_gallery', function(photos) { | ||
if (!photos || !photos.length) return ''; | ||
const content = photos.map(photo => ` | ||
<div class="post-gallery-image"> | ||
<img src="${this.url_for(photo)}" itemprop="contentUrl"> | ||
</div>`).join(''); | ||
return `<div class="post-gallery" itemscope itemtype="http://schema.org/ImageGallery"> | ||
${content} | ||
</div>`; | ||
}); | ||
hexo.extend.helper.register('post_edit', function(src) { | ||
@@ -41,38 +51,7 @@ const { theme } = this; | ||
hexo.extend.helper.register('post_nav', function(post) { | ||
const { theme } = this; | ||
if (theme.post_navigation === false || (!post.prev && !post.next)) return ''; | ||
const prev = theme.post_navigation === 'right' ? post.prev : post.next; | ||
const next = theme.post_navigation === 'right' ? post.next : post.prev; | ||
const left = prev ? ` | ||
<a href="${this.url_for(prev.path)}" rel="prev" title="${prev.title}"> | ||
<i class="fa fa-chevron-left"></i> ${prev.title} | ||
</a>` : ''; | ||
const right = next ? ` | ||
<a href="${this.url_for(next.path)}" rel="next" title="${next.title}"> | ||
${next.title} <i class="fa fa-chevron-right"></i> | ||
</a>` : ''; | ||
return ` | ||
<div class="post-nav"> | ||
<div class="post-nav-item">${left}</div> | ||
<div class="post-nav-item">${right}</div> | ||
</div>`; | ||
}); | ||
hexo.extend.helper.register('gitalk_md5', function(path) { | ||
const str = this.url_for(path); | ||
str.replace('index.html', ''); | ||
return crypto.createHash('md5').update(str).digest('hex'); | ||
}); | ||
hexo.extend.helper.register('canonical', function() { | ||
// https://support.google.com/webmasters/answer/139066 | ||
const { permalink } = hexo.config; | ||
let url = this.url.replace(/index\.html$/, ''); | ||
if (!permalink.endsWith('.html')) { | ||
url = url.replace(/\.html$/, ''); | ||
} | ||
return `<link rel="canonical" href="${url}">`; | ||
}); | ||
/** | ||
@@ -79,0 +58,0 @@ * Get page path given a certain language tag |
@@ -11,3 +11,3 @@ /* global hexo */ | ||
hexo.extend.helper.register('next_config', function() { | ||
const { config, theme, next_version } = this; | ||
const { config, theme, next_version, __ } = this; | ||
const exportConfig = { | ||
@@ -28,3 +28,9 @@ hostname : parse(config.url).hostname || config.url, | ||
motion : theme.motion, | ||
prism : config.prismjs.enable && !config.prismjs.preprocess | ||
prism : config.prismjs.enable && !config.prismjs.preprocess, | ||
i18n : { | ||
placeholder: __('search.placeholder'), | ||
empty : __('search.empty', '${query}'), | ||
hits_time : __('search.hits_time', '${hits}', '${time}'), | ||
hits : __('search.hits', '${hits}') | ||
} | ||
}; | ||
@@ -36,4 +42,3 @@ if (config.algolia && theme.algolia_search && theme.algolia_search.enable) { | ||
indexName: config.algolia.indexName, | ||
hits : theme.algolia_search.hits, | ||
labels : theme.algolia_search.labels | ||
hits : theme.algolia_search.hits | ||
}; | ||
@@ -40,0 +45,0 @@ } |
@@ -7,29 +7,25 @@ /* global hexo */ | ||
const { config, theme } = this; | ||
const vendors = { | ||
anime: 'lib/anime.min.js' | ||
}; | ||
const vendors = ['anime']; | ||
if (config.prismjs.enable && !config.prismjs.preprocess) { | ||
vendors.prism = '//cdn.jsdelivr.net/npm/prismjs@1/components/prism-core.min.js'; | ||
vendors.prism_autoloader = '//cdn.jsdelivr.net/npm/prismjs@1/plugins/autoloader/prism-autoloader.min.js'; | ||
vendors.push('prism', 'prism_autoloader'); | ||
if (config.prismjs.line_number) { | ||
vendors.prism_line_numbers = '//cdn.jsdelivr.net/npm/prismjs@1/plugins/line-numbers/prism-line-numbers.min.js'; | ||
vendors.push('prism_line_numbers'); | ||
} | ||
} | ||
if (theme.pjax) { | ||
vendors.pjax = '//cdn.jsdelivr.net/gh/next-theme/pjax@0/pjax.min.js'; | ||
vendors.push('pjax'); | ||
} | ||
if (theme.fancybox) { | ||
vendors.jquery = '//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js'; | ||
vendors.fancybox = '//cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.js'; | ||
vendors.push('jquery', 'fancybox'); | ||
} | ||
if (theme.mediumzoom) { | ||
vendors.mediumzoom = '//cdn.jsdelivr.net/npm/medium-zoom@1/dist/medium-zoom.min.js'; | ||
vendors.push('mediumzoom'); | ||
} | ||
if (theme.lazyload) { | ||
vendors.lazyload = '//cdn.jsdelivr.net/npm/lozad@1/dist/lozad.min.js'; | ||
vendors.push('lazyload'); | ||
} | ||
if (theme.pangu) { | ||
vendors.pangu = '//cdn.jsdelivr.net/npm/pangu@4/dist/browser/pangu.min.js'; | ||
vendors.push('pangu'); | ||
} | ||
return vendors; | ||
}); |
@@ -8,5 +8,3 @@ /** | ||
module.exports = ctx => function(args) { | ||
args = args.join('').split('@'); | ||
const feature = args[0]; | ||
const periods = args[1] || 'current'; | ||
const [feature, periods = 'current'] = args.join('').split('@'); | ||
@@ -13,0 +11,0 @@ if (!feature) { |
@@ -8,5 +8,3 @@ /** | ||
module.exports = ctx => function(args) { | ||
args = args.join(' ').split('@'); | ||
const classes = args[0] || 'default'; | ||
const text = args[1] || ''; | ||
const [classes = 'default', text = ''] = args.join(' ').split('@'); | ||
@@ -13,0 +11,0 @@ if (!text) ctx.log.warn('Label text must be defined!'); |
@@ -7,7 +7,3 @@ /** | ||
module.exports = function(args, content) { | ||
const image = args[0] || '/images/avatar.gif'; | ||
const delimiter = args[1] || '|'; | ||
const comment = args[2] || '%'; | ||
module.exports = function([image = '/images/avatar.gif', delimiter = '|', comment = '%'], content) { | ||
const links = content.split('\n').filter(line => line.trim() !== '').map(line => { | ||
@@ -14,0 +10,0 @@ const item = line.split(delimiter).map(arg => arg.trim()); |
@@ -10,6 +10,6 @@ /** | ||
module.exports = function(args, content) { | ||
return `<pre class="mermaid" style="text-align: center;"> | ||
return `<div class="mermaid"> | ||
${args.join(' ')} | ||
${escapeHTML(content)} | ||
</pre>`; | ||
</div>`; | ||
}; |
@@ -14,3 +14,2 @@ /** | ||
const matches = []; | ||
let match; | ||
@@ -24,10 +23,5 @@ let tabId = 0; | ||
while ((match = tabBlock.exec(content)) !== null) { | ||
matches.push(match[1]); | ||
matches.push(match[2]); | ||
} | ||
let [caption = '', icon = ''] = match[1].split('@'); | ||
let postContent = match[2]; | ||
for (let i = 0; i < matches.length; i += 2) { | ||
let [caption = '', icon = ''] = matches[i].split('@'); | ||
let postContent = matches[i + 1]; | ||
postContent = ctx.render.renderSync({ text: postContent, engine: 'markdown' }).trim(); | ||
@@ -34,0 +28,0 @@ |
/* global instantsearch, algoliasearch, CONFIG */ | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const algoliaSettings = CONFIG.algolia; | ||
const { indexName, appID, apiKey } = algoliaSettings; | ||
const { indexName, appID, apiKey, hits } = CONFIG.algolia; | ||
@@ -18,3 +17,3 @@ const search = instantsearch({ | ||
window.pjax && search.on('render', () => { | ||
window.pjax.refresh(document.getElementById('algolia-hits')); | ||
window.pjax.refresh(document.querySelector('.algolia-hits')); | ||
}); | ||
@@ -25,3 +24,3 @@ | ||
instantsearch.widgets.configure({ | ||
hitsPerPage: algoliaSettings.hits.per_page || 10 | ||
hitsPerPage: hits.per_page || 10 | ||
}), | ||
@@ -31,3 +30,3 @@ | ||
container : '.search-input-container', | ||
placeholder : algoliaSettings.labels.input_placeholder, | ||
placeholder : CONFIG.i18n.placeholder, | ||
// Hide default icons of algolia search | ||
@@ -43,14 +42,14 @@ showReset : false, | ||
instantsearch.widgets.stats({ | ||
container: '#algolia-stats', | ||
container: '.algolia-stats', | ||
templates: { | ||
text: data => { | ||
const stats = algoliaSettings.labels.hits_stats | ||
const stats = CONFIG.i18n.hits_time | ||
.replace(/\$\{hits}/, data.nbHits) | ||
.replace(/\$\{time}/, data.processingTimeMS); | ||
return `${stats} | ||
<span class="algolia-powered"> | ||
<img src="${CONFIG.root}images/algolia_logo.svg" alt="Algolia"> | ||
</span> | ||
<hr>`; | ||
return `<span>${stats}</span> | ||
<img src="${CONFIG.root}images/logo-algolia-nebula-blue-full.svg" alt="Algolia">`; | ||
} | ||
}, | ||
cssClasses: { | ||
text: 'search-stats' | ||
} | ||
@@ -60,11 +59,19 @@ }), | ||
instantsearch.widgets.hits({ | ||
container: '#algolia-hits', | ||
templates: { | ||
container : '.algolia-hits', | ||
escapeHTML: false, | ||
templates : { | ||
item: data => { | ||
const link = data.permalink ? data.permalink : CONFIG.root + data.path; | ||
return `<a href="${link}" class="algolia-hit-item-link">${data._highlightResult.title.value}</a>`; | ||
const { title, excerpt, excerptStrip, contentStripTruncate } = data._highlightResult; | ||
let result = `<a href="${data.permalink}" class="search-result-title">${title.value}</a>`; | ||
const content = excerpt || excerptStrip || contentStripTruncate; | ||
if (content && content.value) { | ||
const div = document.createElement('div'); | ||
div.innerHTML = content.value; | ||
result += `<a href="${data.permalink}"><p class="search-result">${div.textContent.substr(0, 100)}...</p></a>`; | ||
} | ||
return result; | ||
}, | ||
empty: data => { | ||
return `<div id="algolia-hits-empty"> | ||
${algoliaSettings.labels.hits_empty.replace(/\$\{query}/, data.query)} | ||
${CONFIG.i18n.empty.replace(/\$\{query}/, data.query)} | ||
</div>`; | ||
@@ -74,3 +81,3 @@ } | ||
cssClasses: { | ||
item: 'algolia-hit-item' | ||
list: 'search-result-list' | ||
} | ||
@@ -80,3 +87,3 @@ }), | ||
instantsearch.widgets.pagination({ | ||
container: '#algolia-pagination', | ||
container: '.algolia-pagination', | ||
scrollTo : false, | ||
@@ -83,0 +90,0 @@ showFirst: false, |
@@ -167,3 +167,3 @@ /* global CONFIG */ | ||
const keywords = searchText.split(/[-\s]+/); | ||
const resultContent = document.getElementById('search-result'); | ||
const container = document.querySelector('.search-result-container'); | ||
let resultItems = []; | ||
@@ -175,5 +175,7 @@ if (searchText.length > 0) { | ||
if (keywords.length === 1 && keywords[0] === '') { | ||
resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x"></i></div>'; | ||
container.classList.add('no-result'); | ||
container.innerHTML = '<div class="search-result-icon"><i class="fa fa-search fa-5x"></i></div>'; | ||
} else if (resultItems.length === 0) { | ||
resultContent.innerHTML = '<div id="no-result"><i class="far fa-frown fa-5x"></i></div>'; | ||
container.classList.add('no-result'); | ||
container.innerHTML = '<div class="search-result-icon"><i class="far fa-frown fa-5x"></i></div>'; | ||
} else { | ||
@@ -188,4 +190,9 @@ resultItems.sort((left, right) => { | ||
}); | ||
resultContent.innerHTML = `<ul class="search-result-list">${resultItems.map(result => result.item).join('')}</ul>`; | ||
window.pjax && window.pjax.refresh(resultContent); | ||
const stats = CONFIG.i18n.hits.replace(/\$\{hits}/, resultItems.length); | ||
container.classList.remove('no-result'); | ||
container.innerHTML = `<div class="search-stats">${stats}</div> | ||
<hr> | ||
<ul class="search-result-list">${resultItems.map(result => result.item).join('')}</ul>`; | ||
window.pjax && window.pjax.refresh(container); | ||
} | ||
@@ -192,0 +199,0 @@ }; |
@@ -15,6 +15,6 @@ /* global NexT, CONFIG */ | ||
if (!siteNav) return; | ||
const animateAction = siteNav.classList.contains('site-nav-on'); | ||
const animateAction = document.body.classList.contains('site-nav-on'); | ||
const height = NexT.utils.getComputedStyle(siteNav); | ||
siteNav.style.height = animateAction ? height : 0; | ||
const toggle = () => siteNav.classList.toggle('site-nav-on'); | ||
const toggle = () => document.body.classList.toggle('site-nav-on'); | ||
const begin = () => { | ||
@@ -21,0 +21,0 @@ siteNav.style.overflow = 'hidden'; |
@@ -13,3 +13,3 @@ /* global CONFIG */ | ||
window.addEventListener('mouseup', this.mouseupHandler.bind(this)); | ||
document.querySelector('#sidebar-dimmer').addEventListener('click', this.clickHandler.bind(this)); | ||
document.querySelector('.sidebar-dimmer').addEventListener('click', this.clickHandler.bind(this)); | ||
document.querySelector('.sidebar-toggle').addEventListener('click', this.clickHandler.bind(this)); | ||
@@ -16,0 +16,0 @@ window.addEventListener('sidebar:show', this.showSidebar); |
@@ -74,3 +74,5 @@ /* global NexT, CONFIG */ | ||
registerCopyCode: function() { | ||
document.querySelectorAll('figure.highlight').forEach(element => { | ||
let figure = document.querySelectorAll('figure.highlight'); | ||
if (figure.length === 0) figure = document.querySelectorAll('pre'); | ||
figure.forEach(element => { | ||
element.querySelectorAll('.code .line span').forEach(span => { | ||
@@ -82,6 +84,7 @@ span.classList.forEach(name => { | ||
if (!CONFIG.copycode) return; | ||
element.insertAdjacentHTML('beforeend', '<div class="copy-btn"><i class="fa fa-clipboard fa-fw"></i></div>'); | ||
element.insertAdjacentHTML('beforeend', '<div class="copy-btn"><i class="fa fa-copy fa-fw"></i></div>'); | ||
const button = element.querySelector('.copy-btn'); | ||
button.addEventListener('click', () => { | ||
const code = [...button.parentNode.querySelectorAll('.code .line')].map(line => line.innerText).join('\n'); | ||
const lines = element.querySelector('.code') || element.querySelector('code'); | ||
const code = lines.innerText; | ||
const ta = document.createElement('textarea'); | ||
@@ -105,3 +108,3 @@ ta.style.top = window.scrollY + 'px'; // Prevent page scrolling | ||
setTimeout(() => { | ||
button.querySelector('i').className = 'fa fa-clipboard fa-fw'; | ||
button.querySelector('i').className = 'fa fa-copy fa-fw'; | ||
}, 300); | ||
@@ -148,5 +151,3 @@ }); | ||
if (backToTop || readingProgressBar) { | ||
const docHeight = document.querySelector('.container').offsetHeight; | ||
const winHeight = window.innerHeight; | ||
const contentHeight = docHeight > winHeight ? docHeight - winHeight : document.body.scrollHeight - winHeight; | ||
const contentHeight = document.body.scrollHeight - window.innerHeight; | ||
const scrollPercent = contentHeight > 0 ? Math.min(100 * window.scrollY / contentHeight, 100) : 0; | ||
@@ -153,0 +154,0 @@ if (backToTop) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
166
2
496029
248
2295
5