Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: file load order and fallback #449

Merged
merged 2 commits into from
Jul 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _config.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ sidebar:

# Comment Systems
# Available value of "use":
# disqus | disqus_click | changyan | livere(laibili)
# disqus | disqus_click | changyan | livere
comment:
use:
shortname: # duoshuo or disqus shortname
Expand Down
121 changes: 69 additions & 52 deletions layout/_partial/config_font.ejs
Original file line number Diff line number Diff line change
@@ -1,52 +1,69 @@
<!-- Import Roboto -->
<% if(theme.fonts.use === "google") { %>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
<% } else if(theme.fonts.use === "ustc") { %>
<link href="https://fonts.proxy.ustclug.org/css?family=Roboto:300,400,500" rel="stylesheet">
<% } else if(theme.fonts.use === "custom") { %>
<link href="<%= theme.fonts.custom_font_host %>/css?family=Roboto:300,400,500" rel="stylesheet">
<% } else if(theme.fonts.use === "baomitu") { %>
<style>
@font-face {
font-family: Roboto;
font-style: normal;
font-weight: 300;
src: url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-300.eot);
src: local('Roboto'),local('Roboto-Normal'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-300.eot?#iefix) format('embedded-opentype'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-300.woff2) format('woff2'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-300.woff) format('woff'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-300.ttf) format('truetype'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-300.svg#Roboto) format('svg')
}

@font-face {
font-family: Roboto;
font-style: normal;
font-weight: regular;
src: url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-regular.eot);
src: local('Roboto'),local('Roboto-Normal'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-regular.eot?#iefix) format('embedded-opentype'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-regular.woff2) format('woff2'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-regular.woff) format('woff'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-regular.ttf) format('truetype'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-regular.svg#Roboto) format('svg')
}

@font-face {
font-family: Roboto;
font-style: normal;
font-weight: 500;
src: url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-500.eot);
src: local('Roboto'),local('Roboto-Normal'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-500.eot?#iefix) format('embedded-opentype'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-500.woff2) format('woff2'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-500.woff) format('woff'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-500.ttf) format('truetype'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-500.svg#Roboto) format('svg')
}
</style>
<% } %>

<!-- Import Material Icon -->
<% if(theme.vendors.material_icons) { %>
<link rel="preload" href="<%= theme.vendors.material_icons %>" as="style" onload="this.rel='stylesheet'">
<% } else { %>
<style>
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url(<%- url_for('fonts/MaterialIcons-Regular.woff2') %>) format('woff2'),
url(<%- url_for('fonts/MaterialIcons-Regular.woff') %>) format('woff'),
url(<%- url_for('fonts/MaterialIcons-Regular.ttf') %>) format('truetype');
}
</style>
<% } %>
<!-- Import Roboto -->
<% if(theme.fonts.use === "google") { %>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
<% } else if(theme.fonts.use === "ustc") { %>
<link href="https://fonts.proxy.ustclug.org/css?family=Roboto:300,400,500" rel="stylesheet">
<% } else if(theme.fonts.use === "custom") { %>
<link href="<%= theme.fonts.custom_font_host %>/css?family=Roboto:300,400,500" rel="stylesheet">
<% } else if(theme.fonts.use === "baomitu") { %>
<style>
@font-face {
font-family: Roboto;
font-style: normal;
font-weight: 300;
src: url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-300.eot);
src: local('Roboto'),local('Roboto-Normal'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-300.eot?#iefix) format('embedded-opentype'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-300.woff2) format('woff2'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-300.woff) format('woff'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-300.ttf) format('truetype'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-300.svg#Roboto) format('svg')
}

@font-face {
font-family: Roboto;
font-style: normal;
font-weight: regular;
src: url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-regular.eot);
src: local('Roboto'),local('Roboto-Normal'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-regular.eot?#iefix) format('embedded-opentype'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-regular.woff2) format('woff2'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-regular.woff) format('woff'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-regular.ttf) format('truetype'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-regular.svg#Roboto) format('svg')
}

@font-face {
font-family: Roboto;
font-style: normal;
font-weight: 500;
src: url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-500.eot);
src: local('Roboto'),local('Roboto-Normal'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-500.eot?#iefix) format('embedded-opentype'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-500.woff2) format('woff2'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-500.woff) format('woff'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-500.ttf) format('truetype'),url(https://lib.baomitu.com/fonts/roboto/roboto-v15-latin-500.svg#Roboto) format('svg')
}
</style>
<% } %>

<!-- Import Material Icon -->
<% if(theme.vendors.material_icons) { %>
<link rel="stylesheet" href="<%= theme.vendors.material_icons %>">
<% } else if(theme.vendors.materialcdn) { % >
<style>
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url(<%- url_for(theme.vendors.materialcdn + '/fonts/MaterialIcons-Regular.woff2') %>) format('woff2'),
url(<%- url_for(theme.vendors.materialcdn + '/fonts/MaterialIcons-Regular.woff') %>) format('woff'),
url(<%- url_for(theme.vendors.materialcdn + '/fonts/MaterialIcons-Regular.ttf') %>) format('truetype');
}
</style>
<% } else if(theme.fonts.use === "google") { % >
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<% } else if(theme.fonts.use === "ustc") { %>
<link href="https://fonts.proxy.ustclug.org/icon?family=Material+Icons" rel="stylesheet">
<% } else { %>
<style>
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url(<%- url_for('fonts/MaterialIcons-Regular.woff2') %>) format('woff2'),
url(<%- url_for('fonts/MaterialIcons-Regular.woff') %>) format('woff'),
url(<%- url_for('fonts/MaterialIcons-Regular.ttf') %>) format('truetype');
}
</style>
<% } %>
8 changes: 6 additions & 2 deletions layout/_partial/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,11 @@

<% if(theme.scheme === 'Isolation') { %>
<% if(theme.vendors.fontawesome) { %>
<link rel="preload" href="<%= theme.vendors.fontawesome %>" as="style" onload="this.rel='stylesheet'">
<link rel="stylesheet" href="<%= theme.vendors.fontawesome %>">
<% } else if(theme.vendors.materialcdn) { % >
<link rel="stylesheet" href="<%= url_for(theme.vendors.materialcdn + '/css/fontawesome.min.css') %>">
<% } else { %>
<link rel="preload" href="<%= url_for('css/fontawesome.min.css') %>" as="style" onload="this.rel='stylesheet'">
<link rel="stylesheet" href="<%= url_for('css/fontawesome.min.css') %>">
<% } %>
<% } %>

Expand All @@ -147,6 +149,8 @@
<!-- Import jQuery -->
<% if(theme.vendors.jquery) { %>
<%- jsLsload({path:(theme.vendors.jquery),key:'jq_js'}) %>
<% } else if(theme.vendors.materialcdn) { %>
<%- jsLsload({path:(theme.vendors.materialcdn + '/js/jquery.min.js'),key:'jq_js'}) %>
<% } else { %>
<%- jsLsload({path:('js/jquery.min.js'),key:'jq_js'}) %>
<% } %>
Expand Down
2 changes: 2 additions & 0 deletions layout/_partial/import_js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
<% if ( (is_post()) ) { %>
<% if(theme.vendors.prettify) { %>
<%- jsLsload({path:(theme.vendors.prettify),key:'prettify_js'}) %>
<% } else if(theme.vendors.materialcdn) { % >
<%- jsLsload({path:(theme.vendors.materialcdn + '/js/prettify.min.js'),key:'prettify_js'}) %>
<% } else { %>
<%- jsLsload({path:('js/prettify.min.js'),key:'prettify_js'}) %>
<% } %>
Expand Down
4 changes: 3 additions & 1 deletion layout/_widget/mathjax.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
</script>
<% if(theme.vendors.mathjax) { %>
<script src="<%= theme.vendors.mathjax + '?config=TeX-AMS-MML_HTMLorMML' %>"></script>
<%}else{%>
<% } else if(theme.vendors.materialcdn) { % >
<script type="text/javascript" src="<%= url_for(theme.vendors.materialcdn + '/js/MathJax.js?config=TeX-AMS-MML_HTMLorMML') %>"></script>
<% } else { %>
<script type="text/javascript" src="<%= url_for('js/MathJax.js?config=TeX-AMS-MML_HTMLorMML') %>"></script>
<%}%>
2 changes: 2 additions & 0 deletions layout/_widget/nprogress.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<% if(theme.vendors.nprogress) { %>
<%- jsLsload({path:(theme.vendors.nprogress),key:'np_js'}) %>
<% } else if(theme.vendors.materialcdn) { % >
<%- jsLsload({path:(theme.vendors.materialcdn + '/js/nprogress.js'),key:'np_js'}) %>
<% } else { %>
<%- jsLsload({path:('js/nprogress.js'),key:'np_js'}) %>
<% } %>
Expand Down