Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996436
get-fonts.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1021 B
Referenced Files
None
Subscribers
None
get-fonts.ts
View Options
import
{
readFile
}
from
"fs/promises"
;
import
{
constructURL
,
download
}
from
"google-fonts-helper"
;
import
{
target_locreq
}
from
"./target-locreq.js"
;
export
const
FONTS_CONFIG_PATH
=
"src/fonts.json"
;
export
async
function
getFonts
(
_
:
Record
<
string
,
string
|
boolean
>
=
{})
{
const
fonts_config_path
=
target_locreq
.
resolve
(
FONTS_CONFIG_PATH
);
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const
fonts_config
=
JSON
.
parse
(
await
readFile
(
fonts_config_path
,
"utf8"
));
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
const
fonts_url
=
constructURL
(
fonts_config
.
googleFonts
);
if
(
!
fonts_url
)
{
throw
new
Error
(
"Invalid font config"
);
}
const
downloader
=
download
(
fonts_url
,
{
base64
:
false
,
overwriting
:
false
,
outputDir
:
target_locreq
.
resolve
(
"public/dist/fonts"
),
stylePath
:
"fonts.css"
,
fontsDir
:
"./"
,
fontsPath
:
"/dist/fonts"
,
});
await
downloader
.
execute
();
console
.
log
(
"Downloaded new fonts pack"
);
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Tue, Dec 24, 14:03 (17 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557258
Default Alt Text
get-fonts.ts (1021 B)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment