diff --git a/_config.yml b/_config.yml
index 02758d9..76e5f65 100644
--- a/_config.yml
+++ b/_config.yml
@@ -337,6 +337,10 @@ calendar:
# See: https://theme-next.js.org/docs/theme-settings/miscellaneous
# ---------------------------------------------------------------
+# Preconnect CDN for fonts and plugins.
+# For more information: https://www.w3.org/TR/resource-hints/#preconnect
+preconnect: false
+
# Set the text alignment in posts / pages.
text_align:
# Available values: start | end | left | right | center | justify | justify-all | match-parent
diff --git a/layout/_partials/head/head.njk b/layout/_partials/head/head.njk
index 0f54b60..6f26306 100644
--- a/layout/_partials/head/head.njk
+++ b/layout/_partials/head/head.njk
@@ -3,6 +3,8 @@
+{{ next_pre() }}
+
{%- if theme.favicon.apple_touch_icon %}
{%- endif %}
diff --git a/scripts/helpers/engine.js b/scripts/helpers/engine.js
index 0e9b827..2492719 100644
--- a/scripts/helpers/engine.js
+++ b/scripts/helpers/engine.js
@@ -28,6 +28,26 @@ hexo.extend.helper.register('next_js', function(file, pjax = false) {
return ``;
});
+hexo.extend.helper.register('next_pre', function() {
+ const { preconnect } = this.theme;
+ if (!preconnect) return '';
+ const { enable, host } = this.theme.font;
+ const { internal, plugins } = this.theme.vendors;
+ const links = {
+ local : '',
+ jsdelivr: 'https://cdn.jsdelivr.net',
+ unpkg : 'https://unpkg.com',
+ cdnjs : 'https://cdnjs.cloudflare.com'
+ };
+ const h = enable ? host || 'https://fonts.googleapis.com' : '';
+ const i = links[internal];
+ const p = links[plugins];
+ const results = [...new Set([h, i, p].filter(origin => origin))].map(
+ origin => ``
+ );
+ return results.join('\n');
+});
+
hexo.extend.helper.register('post_gallery', function(photos) {
if (!photos || !photos.length) return '';
const content = photos.map(photo => `