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

Subset fontawesome fonts #194

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 5 additions & 14 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ css:
- /assets/css/main.css

js:
all:
- /assets/js/boot.js

docs:
- /assets/js/docs.js

Expand Down Expand Up @@ -59,22 +56,13 @@ builds:
integrity: sha384-i14qZ6FYmJXQABb+YG5tH4NXjKOLznxsr5jFsNiJNRcQ77978BoUif762EQyydgt

font-face:
fontawesome:
regular:
- https://cdn.jsdelivr.net/fontawesome/4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0
- https://cdn.jsdelivr.net/fontawesome/4.7.0/fonts/fontawesome-webfont.woff2?v=4.7.0

sourcecodepro:
light:
- https://fonts.gstatic.com/s/sourcecodepro/v6/leqv3v-yTsJNC7nFznSMqSP2LEk6lMzYsRqr3dHFImA.woff2
- /assets/fonts/source-code-pro-v7-latin-300.woff2
semi-bold:
- https://fonts.gstatic.com/s/sourcecodepro/v6/leqv3v-yTsJNC7nFznSMqczFoXZ-Kj537nB_-9jJhlA.woff2
- /assets/fonts/source-code-pro-v7-latin-600.woff2

vendor:
css:
- href: https://cdn.jsdelivr.net/fontawesome/4.7.0/css/font-awesome.min.css
integrity: sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN

js:
- href: https://embed.runkit.com/
async: true
Expand All @@ -92,11 +80,14 @@ google_analytics:

exclude:
- node_modules
- tools
- Gemfile
- gulpfile.js
- icons.js
- LICENSE
- package.json
- package-lock.json
- requirements.txt
- "*.lock"
- "*.log"
- "*.md"
Expand Down
3 changes: 1 addition & 2 deletions _headers
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ hints:
all: [
'</sw.js>; rel=serviceworker',
'<https://cdn.jsdelivr.net/>; rel=preconnect; pr=1.0; crossorigin',
'<//runkit.com/>; rel=dns-prefetch; pr=0.25; crossorigin',
'<//cdn.carbonads.com/>; rel=dns-prefetch; pr=0.25',
'<//srv.carbonads.net/>; rel=dns-prefetch; pr=0.25'
]
Expand Down Expand Up @@ -180,7 +179,7 @@ Add link header for doc pages.

{% for res in site.builds %}
/docs/{{ res[0] }}*
Link: <{{ res[1].href }}>; rel=preload; as=script; pr=1.0; crossorigin
Link: {{ docs | join:', ' }}, <{{ res[1].href }}>; rel=preload; as=script; pr=1.0; crossorigin
{% endfor %}

{% comment %}
Expand Down
10 changes: 0 additions & 10 deletions _layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@
<link rel="prerender" href="/docs/{{ site.release }}" pr="1.0">
{% endif %}
<link rel="stylesheet" href="/assets/css/main.css">
<noscript>
{% for res in site.vendor.css %}
{% assign protocol = res.href | slice:0,6 %}
{% if res.integrity and protocol == 'https:' %}
<link rel="stylesheet" href="{{ res.href }}" integrity="{{ res.integrity }}" crossorigin>
{% else %}
<link rel="stylesheet" href="{{ res.href }}">
{% endif %}
{% endfor %}
</noscript>
<script src="/assets/js/boot.js" async></script>
</head>
<body class="layout-{{ page.layout }}">
Expand Down
15 changes: 10 additions & 5 deletions assets/css/_font-face.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
/* source-code-pro-300 - latin */
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 400;
src: local('Source Code Pro Light'), local('SourceCodePro-Light'), url({{ site.font-face.sourcecodepro.light | first }}) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
font-display: swap;
src: local('Source Code Pro Light'), local('SourceCodePro-Light'),
url('../fonts/source-code-pro-v7-latin-300.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('../fonts/source-code-pro-v7-latin-300.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}

/* source-code-pro-600 - latin */
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 700;
src: local('Source Code Pro Semibold'), local('SourceCodePro-Semibold'), url({{ site.font-face.sourcecodepro.semi-bold | first }}) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
font-display: swap;
src: local('Source Code Pro Semibold'), local('SourceCodePro-Semibold'),
url('../fonts/source-code-pro-v7-latin-600.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('../fonts/source-code-pro-v7-latin-600.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
Binary file added assets/fonts/source-code-pro-v7-latin-300.woff
Binary file not shown.
Binary file not shown.
Binary file added assets/fonts/source-code-pro-v7-latin-600.woff
Binary file not shown.
Binary file added assets/fonts/source-code-pro-v7-latin-600.woff2
Binary file not shown.
23 changes: 0 additions & 23 deletions assets/js/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,12 @@
var head = document.head,
rootEl = document.documentElement

function addStyleSheet(res) {
var link = document.createElement('link')

if (res.integrity &&
res.href.slice(0, 6) === 'https:') {
link.crossOrigin = 'anonymous'
link.integrity = res.integrity
}

link.rel = 'stylesheet'
link.href = res.href
head.appendChild(link)
}

function toggleOffline() {
rootEl.classList.toggle('offline')
}

/*--------------------------------------------------------------------------*/

{% assign resources = site.data.init.array %}
{% for res in site.vendor.css %}
{% assign object = res | jsonify %}
{% assign resources = resources | push:object %}
{% endfor %}

// Add asynchronous style sheets.
[{{ resources | join:',' }}].forEach(addStyleSheet)

{% if jekyll.environment == 'production' %}
// Register service worker.
if ('serviceWorker' in navigator) {
Expand Down
1 change: 0 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ gulp.task('build-vendor', () =>
const push = value => hrefs.push(value.href || value)

_.forOwn(parsed.builds, push)
_.forOwn(parsed['font-face'], styles => _.forOwn(styles, hrefs => hrefs.forEach(push)))
_.forOwn(parsed.vendor, items => items.forEach(push))
_.remove(hrefs, href => href.endsWith('/'))

Expand Down
Loading