From 4af8328fe7a73fccf82f0ac92dbaa0b1f4e50874 Mon Sep 17 00:00:00 2001 From: 1v9 Date: Sun, 24 Feb 2019 13:22:02 +0800 Subject: [PATCH] Refactor: Add some options for quicklink --- _config.yml | 14 ++++++++++++-- layout/_third-party/quicklink.swig | 9 ++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/_config.yml b/_config.yml index bb61a12ff0..aa1ad90c05 100644 --- a/_config.yml +++ b/_config.yml @@ -507,10 +507,20 @@ han: false # For more information: https://github.com/vinta/pangu.js pangu: false -# quicklink Support +# Quicklink Support # Dependencies: https://cdn.jsdelivr.net/npm/quicklink/dist/ # Visit https://github.com/GoogleChromeLabs/quicklink for details -quicklink: false +quicklink: + enable: false + timeout: 3000 # Custom a timeout (milliseconds) for prefetching resources + priority: true # Set true to enable fetch() or falls back to XHR + # 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: uri => uri.includes('.xml'), (uri, elem) => elem.hasAttribute('noprefetch') + # ignores: [/\/api\/?/, uri => uri.includes('123.html')] + ignores: # Swiftype Search API Key #swiftype_key: diff --git a/layout/_third-party/quicklink.swig b/layout/_third-party/quicklink.swig index 3cb861b2ae..b2606ee7de 100644 --- a/layout/_third-party/quicklink.swig +++ b/layout/_third-party/quicklink.swig @@ -1,4 +1,4 @@ -{% if theme.quicklink %} +{% if theme.quicklink and theme.quicklink.enable %} {% set quicklink_uri = url_for(theme.vendors._internal + '/quicklink/dist/quicklink.umd.js') %} {% if theme.vendors.quicklink %} {% set quicklink_uri = theme.vendors.quicklink %} @@ -7,10 +7,9 @@