main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | function createUrl (font, weights, subsets) {
|
---|
4 | var params = '?family=' + encodeURIComponent(font);
|
---|
5 |
|
---|
6 | if (weights) {
|
---|
7 | if (!(weights instanceof Array))
|
---|
8 | weights = [weights];
|
---|
9 |
|
---|
10 | params += ':' + weights.join(',');
|
---|
11 | }
|
---|
12 |
|
---|
13 | if (subsets) {
|
---|
14 | if (!(subsets instanceof Array))
|
---|
15 | subsets = [subsets];
|
---|
16 |
|
---|
17 | params += '&subset=' + subsets.join(',');
|
---|
18 | }
|
---|
19 |
|
---|
20 | return 'https://fonts.googleapis.com/css' + params;
|
---|
21 | }
|
---|
22 |
|
---|
23 | exports.addon = function (renderer) {
|
---|
24 | if (process.env.NODE_ENV !== 'production') {
|
---|
25 | require('./__dev__/warnOnMissingDependencies')('hydrate', renderer, ['put']);
|
---|
26 | }
|
---|
27 |
|
---|
28 | if (renderer.client) {
|
---|
29 | renderer.googleFont = function (font, weights, subsets) {
|
---|
30 | var el = document.createElement('link');
|
---|
31 |
|
---|
32 | el.href = createUrl(font, weights, subsets);
|
---|
33 | el.rel = 'stylesheet';
|
---|
34 | el.type = 'text/css';
|
---|
35 |
|
---|
36 | document.head.appendChild(el);
|
---|
37 | };
|
---|
38 | } else {
|
---|
39 | renderer.googleFont = function (font, weights, subsets) {
|
---|
40 | renderer.putRaw("@import url('" + createUrl(font, weights, subsets) + "');");
|
---|
41 | };
|
---|
42 | }
|
---|
43 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.