mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-17 18:22:33 +00:00
Support preconnect hint for CDN (#122)
This commit is contained in:
parent
088c030073
commit
f360c28597
@ -337,6 +337,10 @@ calendar:
|
|||||||
# See: https://theme-next.js.org/docs/theme-settings/miscellaneous
|
# 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.
|
# Set the text alignment in posts / pages.
|
||||||
text_align:
|
text_align:
|
||||||
# Available values: start | end | left | right | center | justify | justify-all | match-parent
|
# Available values: start | end | left | right | center | justify | justify-all | match-parent
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
<meta name="theme-color" content="{{ theme.android_chrome_color }}">
|
<meta name="theme-color" content="{{ theme.android_chrome_color }}">
|
||||||
<meta name="generator" content="Hexo {{ hexo_version }}">
|
<meta name="generator" content="Hexo {{ hexo_version }}">
|
||||||
|
|
||||||
|
{{ next_pre() }}
|
||||||
|
|
||||||
{%- if theme.favicon.apple_touch_icon %}
|
{%- if theme.favicon.apple_touch_icon %}
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="{{ url_for(theme.favicon.apple_touch_icon) }}">
|
<link rel="apple-touch-icon" sizes="180x180" href="{{ url_for(theme.favicon.apple_touch_icon) }}">
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|||||||
@ -28,6 +28,26 @@ hexo.extend.helper.register('next_js', function(file, pjax = false) {
|
|||||||
return `<script ${pjax ? 'data-pjax ' : ''}src="${src}"></script>`;
|
return `<script ${pjax ? 'data-pjax ' : ''}src="${src}"></script>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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 => `<link rel="preconnect" href="${origin}" crossorigin>`
|
||||||
|
);
|
||||||
|
return results.join('\n');
|
||||||
|
});
|
||||||
|
|
||||||
hexo.extend.helper.register('post_gallery', function(photos) {
|
hexo.extend.helper.register('post_gallery', function(photos) {
|
||||||
if (!photos || !photos.length) return '';
|
if (!photos || !photos.length) return '';
|
||||||
const content = photos.map(photo => `
|
const content = photos.map(photo => `
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user