Skip to content

Commit c2e35c4

Browse files
committed
#52: serve Quantico font
1 parent 597343d commit c2e35c4

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"type": "module",
44
"main": "src/server/index.js",
55
"dependencies": {
6+
"@fontsource/quantico": "^5.0.1",
67
"koa": "^2.14.1",
78
"koa-bodyparser": "^4.3.0",
89
"koa-compress": "^5.1.1",

src/server/dependencies.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1-
import { sendStaticFile } from './helpers/send-static-file.js'
1+
import send from 'koa-send'
22

33
export const registerDependencyRoutes = (router) => {
44
router.get('/dependencies/vue.js', sendStaticFile('node_modules/vue/dist/vue.esm-browser.js'))
55
router.get('/dependencies/vue3-sfc-loader.js', sendStaticFile('node_modules/vue3-sfc-loader/dist/vue3-sfc-loader.esm.js'))
6+
67
router.get('/dependencies/normalize.css', sendStaticFile('node_modules/normalize.css/normalize.css'))
8+
9+
serveFontsourceFont(router, 'quantico')
10+
}
11+
12+
// NB! Do _not_ use this with user-supplied values for localFile!
13+
export const sendStaticFile = (localFile) => async (context) => {
14+
await send(context, localFile)
15+
}
16+
17+
export const serveFontsourceFont = (router, fontName) => {
18+
const prefix = `/dependencies/${fontName}/`
19+
20+
router.get(`${prefix}:path*`, async (context) => {
21+
await send(context, context.path.substring(prefix.length), { root: `node_modules/@fontsource/${fontName}` })
22+
})
723
}

src/server/helpers/send-static-file.js

-8
This file was deleted.

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.21.2.tgz#dacafadfc6d7654c3051a66d6fe55b6cb2f2a0b3"
88
integrity sha512-URpaIJQwEkEC2T9Kn+Ai6Xe/02iNaVCuT/PtoRz3GPVJVDpPd7mLo+VddTbhCRU9TXqW5mSrQfXZyi8kDKOVpQ==
99

10+
"@fontsource/quantico@^5.0.1":
11+
version "5.0.1"
12+
resolved "https://registry.yarnpkg.com/@fontsource/quantico/-/quantico-5.0.1.tgz#a83935a353e6d32eb3236c7df193456e9a9beffa"
13+
integrity sha512-Nd2hsZysPSZ0ffMUg0aeSzj9q0P/K/2tHcjqg6IdOdtVFXiMxNEq5qpwUtli1OiTvOu9EKcknQ2JzVkHDOMwtA==
14+
1015
1116
version "3.2.47"
1217
resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.2.47.tgz#3e07c684d74897ac9aa5922c520741f3029267f8"

0 commit comments

Comments
 (0)