Skip to content

Commit 1431abf

Browse files
1v9ivan-nginx
authored andcommitted
Refactor: Add some options for quicklink (theme-next#625)
1 parent 44596eb commit 1431abf

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

_config.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,10 +506,20 @@ han: false
506506
# For more information: https://github.com/vinta/pangu.js
507507
pangu: false
508508

509-
# quicklink Support
509+
# Quicklink Support
510510
# Dependencies: https://cdn.jsdelivr.net/npm/quicklink/dist/
511511
# Visit https://github.com/GoogleChromeLabs/quicklink for details
512-
quicklink: false
512+
quicklink:
513+
enable: false
514+
timeout: 3000 # Custom a timeout (milliseconds) for prefetching resources
515+
priority: true # Set true to enable fetch() or falls back to XHR
516+
# For more flexibility you can add some patterns (RegExp, Function, or Array) to ignores
517+
# See: https://github.com/GoogleChromeLabs/quicklink#custom-ignore-patterns
518+
# Leave ignores as empty if you don't understand what it means
519+
# Example:
520+
# ignores: uri => uri.includes('.xml'), (uri, elem) => elem.hasAttribute('noprefetch')
521+
# ignores: [/\/api\/?/, uri => uri.includes('123.html')]
522+
ignores:
513523

514524
# Swiftype Search API Key
515525
#swiftype_key:

layout/_third-party/quicklink.swig

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% if theme.quicklink %}
1+
{% if theme.quicklink and theme.quicklink.enable %}
22
{% set quicklink_uri = url_for(theme.vendors._internal + '/quicklink/dist/quicklink.umd.js') %}
33
{% if theme.vendors.quicklink %}
44
{% set quicklink_uri = theme.vendors.quicklink %}
@@ -7,10 +7,9 @@
77
<script>
88
window.addEventListener('load', () => {
99
quicklink({
10-
priority: true,
11-
ignores: [
12-
uri => uri.includes('#')
13-
]
10+
timeout: {{ theme.quicklink.timeout }},
11+
priority: {{ theme.quicklink.priority }},
12+
ignores: [uri => uri.includes('#'), {{ theme.quicklink.ignores }}]
1413
});
1514
});
1615
</script>

0 commit comments

Comments
 (0)