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

feat: Add quicklink support

上级 d09c08e6
......@@ -558,6 +558,36 @@ lazyload:
# Available values: gif | block
placeholder: gif
# Quicklink support
# See: https://github.com/GoogleChromeLabs/quicklink/
quicklink:
enable: false
# Quicklink (quicklink.umd.js script) is loaded on demand.
# Add `quicklink: true` in Front-matter of the page or post you need.
# Home page and archive page can be controlled through home and archive options below.
home: true
archive: true
# Initialize quicklink after the load event fires.
delay: true
# Custom a time in milliseconds by which the browser must execute prefetching.
timeout: 10000
# Enable fetch() or falls back to XHR.
priority: true
# For more flexibility you can add some patterns (RegExp, Function, or Array) to ignores.
# See: https://github.com/GoogleChromeLabs/quicklink#custom-ignore-patterns
# ! ---------------------------------------------------------------
# ! Leave "ignores" as empty if you don't understand what it means.
# ! ---------------------------------------------------------------
# Example:
# ignores:
# - /\/api\/?/
# - uri => uri.includes('.zip')
# - (uri, el) => el.hasAttribute('nofollow')
ignores:
# Google AdSense
google_adsense:
enable: false
......@@ -710,3 +740,9 @@ cdn:
# Example:
# lazyload: //cdn.jsdelivr.net/npm/lazyload@2.0.0-rc.2/lazyload.min.js
lazyload:
# # Using version: latest
# See: https://github.com/GoogleChromeLabs/quicklink/
# Example:
# quicklink: //cdn.jsdelivr.net/npm/quicklink@latest/dist/quicklink.umd.js
quicklink:
if theme.quicklink.enable
-
var quicklink_js = "https://cdn.jsdelivr.net/npm/quicklink@1.0.1/dist/quicklink.umd.js"
if (theme.cdn.quicklink) quicklink_js = theme.cdn.quicklink
var loadQuicklink = false
if is_home() && theme.quicklink.home
- loadQuicklink = true
if is_archive() && theme.quicklink.archive
- loadQuicklink = true
if loadQuicklink || ((page && page.quicklink) || (post && post.quicklink))
script(src=quicklink_js)
script.
function initQuicklink() {
quicklink({
timeout: '!{ theme.quicklink.timeout }',
priority: '!{ theme.quicklink.priority }',
ignores: [uri => uri.includes('#'), uri => uri === '!{ url.replace("index.html", '') }', !{ theme.quicklink.ignores }]
});
}
if (!{theme.quicklink.delay}) {
window.addEventListener('load', initQuicklink);
} else {
initQuicklink();
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册