Skip to content

Commit

Permalink
#52: serve Quantico font
Browse files Browse the repository at this point in the history
  • Loading branch information
drweissbrot committed May 27, 2023
1 parent 597343d commit c2e35c4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"type": "module",
"main": "src/server/index.js",
"dependencies": {
"@fontsource/quantico": "^5.0.1",
"koa": "^2.14.1",
"koa-bodyparser": "^4.3.0",
"koa-compress": "^5.1.1",
Expand Down
18 changes: 17 additions & 1 deletion src/server/dependencies.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
import { sendStaticFile } from './helpers/send-static-file.js'
import send from 'koa-send'

export const registerDependencyRoutes = (router) => {
router.get('/dependencies/vue.js', sendStaticFile('node_modules/vue/dist/vue.esm-browser.js'))
router.get('/dependencies/vue3-sfc-loader.js', sendStaticFile('node_modules/vue3-sfc-loader/dist/vue3-sfc-loader.esm.js'))

router.get('/dependencies/normalize.css', sendStaticFile('node_modules/normalize.css/normalize.css'))

serveFontsourceFont(router, 'quantico')
}

// NB! Do _not_ use this with user-supplied values for localFile!
export const sendStaticFile = (localFile) => async (context) => {
await send(context, localFile)
}

export const serveFontsourceFont = (router, fontName) => {
const prefix = `/dependencies/${fontName}/`

router.get(`${prefix}:path*`, async (context) => {
await send(context, context.path.substring(prefix.length), { root: `node_modules/@fontsource/${fontName}` })
})
}
8 changes: 0 additions & 8 deletions src/server/helpers/send-static-file.js

This file was deleted.

5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.21.2.tgz#dacafadfc6d7654c3051a66d6fe55b6cb2f2a0b3"
integrity sha512-URpaIJQwEkEC2T9Kn+Ai6Xe/02iNaVCuT/PtoRz3GPVJVDpPd7mLo+VddTbhCRU9TXqW5mSrQfXZyi8kDKOVpQ==

"@fontsource/quantico@^5.0.1":
version "5.0.1"
resolved "https://registry.yarnpkg.com/@fontsource/quantico/-/quantico-5.0.1.tgz#a83935a353e6d32eb3236c7df193456e9a9beffa"
integrity sha512-Nd2hsZysPSZ0ffMUg0aeSzj9q0P/K/2tHcjqg6IdOdtVFXiMxNEq5qpwUtli1OiTvOu9EKcknQ2JzVkHDOMwtA==

"@vue/[email protected]":
version "3.2.47"
resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.2.47.tgz#3e07c684d74897ac9aa5922c520741f3029267f8"
Expand Down

0 comments on commit c2e35c4

Please sign in to comment.