Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 43c9793

Browse files
fix: fonts are inaccessible (fix #40)(#43)
1 parent e3df028 commit 43c9793

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const removeMd = require('remove-markdown')
2+
const path = require('path')
3+
const fs = require('fs-extra')
24

35
module.exports = (themeConfig, ctx) => {
46
themeConfig = Object.assign(themeConfig, {
@@ -79,6 +81,14 @@ module.exports = (themeConfig, ctx) => {
7981
? themeConfig.paginationComponent
8082
: 'Pagination',
8183
},
84+
ready() {
85+
const dest = ctx.tempPath + '/fonts'
86+
copyFonts(dest)
87+
},
88+
generated() {
89+
const dest = ctx.outDir + '/fonts'
90+
copyFonts(dest)
91+
},
8292
}
8393

8494
/**
@@ -102,3 +112,9 @@ module.exports = (themeConfig, ctx) => {
102112

103113
return config
104114
}
115+
116+
function copyFonts(dest) {
117+
const src = path.resolve(__dirname, 'fonts')
118+
fs.ensureDirSync(dest)
119+
fs.copySync(src, dest)
120+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"eslint-config-sherry": "0.0.1",
6060
"eslint-plugin-prettier": "^3.1.2",
6161
"eslint-plugin-vue": "^6.0.1",
62+
"fs-extra": "^8.1.0",
6263
"husky": "^3.1.0",
6364
"lint-staged": "^9.5.0",
6465
"sort-package-json": "^1.31.0",

styles/font.styl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@
33
font-family: 'PT Serif';
44
font-style: normal;
55
font-weight: 400;
6-
src: local('PT Serif'), local('PTSerif-Regular'), url(/fonts/EJRVQgYoZZY2vCFuvAFbzr-_dSb_nco.woff2) format('woff2');
6+
src: local('PT Serif'), local('PTSerif-Regular'), url(fonts/EJRVQgYoZZY2vCFuvAFbzr-_dSb_nco.woff2) format('woff2');
77
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
88
}
99
/* cyrillic */
1010
@font-face {
1111
font-family: 'PT Serif';
1212
font-style: normal;
1313
font-weight: 400;
14-
src: local('PT Serif'), local('PTSerif-Regular'), url(/fonts/EJRVQgYoZZY2vCFuvAFSzr-_dSb_nco.woff2) format('woff2');
14+
src: local('PT Serif'), local('PTSerif-Regular'), url(fonts/EJRVQgYoZZY2vCFuvAFSzr-_dSb_nco.woff2) format('woff2');
1515
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
1616
}
1717
/* latin-ext */
1818
@font-face {
1919
font-family: 'PT Serif';
2020
font-style: normal;
2121
font-weight: 400;
22-
src: local('PT Serif'), local('PTSerif-Regular'), url(/fonts/EJRVQgYoZZY2vCFuvAFYzr-_dSb_nco.woff2) format('woff2');
22+
src: local('PT Serif'), local('PTSerif-Regular'), url(fonts/EJRVQgYoZZY2vCFuvAFYzr-_dSb_nco.woff2) format('woff2');
2323
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
2424
}
2525
/* latin */
2626
@font-face {
2727
font-family: 'PT Serif';
2828
font-style: normal;
2929
font-weight: 400;
30-
src: local('PT Serif'), local('PTSerif-Regular'), url(/fonts/EJRVQgYoZZY2vCFuvAFWzr-_dSb_.woff2) format('woff2');
30+
src: local('PT Serif'), local('PTSerif-Regular'), url(fonts/EJRVQgYoZZY2vCFuvAFWzr-_dSb_.woff2) format('woff2');
3131
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
3232
}

yarn.lock

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4083,6 +4083,15 @@ fs-extra@^7.0.1:
40834083
jsonfile "^4.0.0"
40844084
universalify "^0.1.0"
40854085

4086+
fs-extra@^8.1.0:
4087+
version "8.1.0"
4088+
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"
4089+
integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==
4090+
dependencies:
4091+
graceful-fs "^4.2.0"
4092+
jsonfile "^4.0.0"
4093+
universalify "^0.1.0"
4094+
40864095
fs-minipass@^1.2.5:
40874096
version "1.2.7"
40884097
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7"
@@ -4365,7 +4374,7 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6
43654374
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.2.tgz#6f0952605d0140c1cfdb138ed005775b92d67b02"
43664375
integrity sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==
43674376

4368-
graceful-fs@^4.2.2:
4377+
graceful-fs@^4.2.0, graceful-fs@^4.2.2:
43694378
version "4.2.3"
43704379
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423"
43714380
integrity sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==

0 commit comments

Comments
 (0)