-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21b6f35
commit 95673fc
Showing
15 changed files
with
465 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { GOOGLE_PROVIDER_NAME } from "./providers/google.js"; | ||
import { LOCAL_PROVIDER_NAME } from "./providers/local.js"; | ||
|
||
export const BUILTIN_PROVIDERS = [GOOGLE_PROVIDER_NAME, LOCAL_PROVIDER_NAME] as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { FontProvider } from './types.js'; | ||
|
||
export function defineFontProvider<TName extends string>(provider: FontProvider<TName>) { | ||
return provider; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { adobe } from './providers/adobe.js'; | ||
|
||
/** TODO: */ | ||
export const fontProviders = { | ||
adobe, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineFontProvider } from '../helpers.js'; | ||
|
||
export function adobe(config: { apiKey: string }) { | ||
return defineFontProvider({ | ||
name: 'adobe', | ||
entrypoint: 'astro/assets/fonts/providers/adobe', | ||
config, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { defineFontProvider } from '../helpers.js'; | ||
|
||
export const GOOGLE_PROVIDER_NAME = 'google'; | ||
|
||
export function google() { | ||
return defineFontProvider({ | ||
name: GOOGLE_PROVIDER_NAME, | ||
entrypoint: 'astro/assets/fonts/providers/google', | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { defineFontProvider } from '../helpers.js'; | ||
|
||
export const LOCAL_PROVIDER_NAME = 'local'; | ||
|
||
export function local() { | ||
return defineFontProvider({ | ||
name: LOCAL_PROVIDER_NAME, | ||
entrypoint: 'astro/assets/fonts/providers/google', | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { BUILTIN_PROVIDERS } from './constants.js'; | ||
import type { GOOGLE_PROVIDER_NAME } from './providers/google.js'; | ||
import type { LOCAL_PROVIDER_NAME } from './providers/local.js'; | ||
|
||
export interface FontProvider<TName extends string> { | ||
name: TName; | ||
entrypoint: string; | ||
config?: Record<string, any>; | ||
} | ||
|
||
type LocalFontFamily = { | ||
provider: LocalProviderName; | ||
// TODO: refine type | ||
src: string; | ||
}; | ||
|
||
type StandardFontFamily<TProvider extends string> = { | ||
provider: TProvider; | ||
}; | ||
|
||
export type FontFamily<TProvider extends string> = TProvider extends LocalProviderName | ||
? LocalFontFamily | ||
: StandardFontFamily<TProvider>; | ||
|
||
export type LocalProviderName = typeof LOCAL_PROVIDER_NAME; | ||
export type GoogleProviderName = typeof GOOGLE_PROVIDER_NAME; | ||
export type BuiltInProvider = (typeof BUILTIN_PROVIDERS)[number]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.