Skip to content

Commit

Permalink
Merge branch 'self-host-font-files' into 'main'
Browse files Browse the repository at this point in the history
Self-host the font-files as fonts.googleapis.com can be very slow

See merge request documentation/uilicious-docs-v3!25
  • Loading branch information
Tai Shi Ling committed Nov 10, 2023
2 parents 4f54fad + c9443f2 commit ed39781
Show file tree
Hide file tree
Showing 29 changed files with 54 additions and 3 deletions.
23 changes: 21 additions & 2 deletions .vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
// It is not compatible with vuepress 1++
//

import path from "node:path";

import { viteBundler } from '@vuepress/bundler-vite'
import { defineUserConfig } from '@vuepress/cli'

import { defaultTheme } from "@vuepress/theme-default";
import { docsearchPlugin } from "@vuepress/plugin-docsearch";
import { tocPlugin } from '@vuepress/plugin-toc'
Expand All @@ -19,7 +24,21 @@ import summaryToSidebar from "./summary-to-sidebar";
// Lets tweak base path to /v3/
let basePath = "/v3/"

export default {
export default defineUserConfig({

// vite config
bundler: viteBundler({
viteOptions: {
resolve: {
alias: {
// this allows us to properly import local font fonts using relative file path
'@styles': path.resolve(__dirname, 'styles')
}
}
},
vuePluginOptions: {},
}),

// Lets tweak base path to /v3/
base: basePath,

Expand Down Expand Up @@ -97,7 +116,7 @@ export default {
lazyLoading: true
})
}
};
});

function googleTagManager(container_id){
return ["script", {}, `<!-- Google Tag Manager -->
Expand Down
34 changes: 33 additions & 1 deletion .vuepress/styles/_typography.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;700&family=Noto+Sans:ital,wght@0,400;0,700;1,400&family=Readex+Pro:wght@200;600&display=swap');
// As fonts.googleapis.com can be very slow!!! We'll host the font files instead.
//@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;700&family=Noto+Sans:ital,wght@0,400;0,700;1,400&family=Readex+Pro:wght@200;600&display=swap');

// header
@font-face {
font-family: 'Readex Pro';
//src: url("/v3/static/fonts/ReadexPro-VariableFont_HEXP,wght.ttf");
src: url(@styles/fonts/ReadexPro-VariableFont_HEXP\,wght.ttf);
}

// normal text
@font-face {
font-family: 'Noto Sans';
src: url(@styles/fonts/NotoSans-Regular.ttf);
}

@font-face {
font-family: 'Noto Sans';
src: url(@styles/fonts/NotoSans-Bold.ttf);
font-weight: bold;
}

@font-face {
font-family: 'Noto Sans';
src: url(@styles/fonts/NotoSans-Italic.ttf);
font-style: italic;
}

// code font face
@font-face {
font-family: 'Fira Code';
src: url(@styles/fonts/FiraCode-VariableFont_wght.ttf);
}

:root {

Expand Down
Binary file not shown.
Binary file added .vuepress/styles/fonts/NotoSans-Black.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/NotoSans-BlackItalic.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/NotoSans-Bold.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/NotoSans-BoldItalic.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/NotoSans-ExtraBold.ttf
Binary file not shown.
Binary file not shown.
Binary file added .vuepress/styles/fonts/NotoSans-ExtraLight.ttf
Binary file not shown.
Binary file not shown.
Binary file added .vuepress/styles/fonts/NotoSans-Italic.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/NotoSans-Light.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/NotoSans-LightItalic.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/NotoSans-Medium.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/NotoSans-MediumItalic.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/NotoSans-Regular.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/NotoSans-SemiBold.ttf
Binary file not shown.
Binary file not shown.
Binary file added .vuepress/styles/fonts/NotoSans-Thin.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/NotoSans-ThinItalic.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/ReadexPro-Bold.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/ReadexPro-ExtraLight.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/ReadexPro-Light.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/ReadexPro-Medium.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/ReadexPro-Regular.ttf
Binary file not shown.
Binary file added .vuepress/styles/fonts/ReadexPro-SemiBold.ttf
Binary file not shown.
Binary file not shown.
Empty file.

0 comments on commit ed39781

Please sign in to comment.