Refactor font loading functions to implement caching for improved performance. The loadSiteOgFonts and loadRehberOgFonts functions now utilize promises to prevent redundant loading, enhancing efficiency. Additionally, minor adjustments were made to ensure consistent font data structure and style definitions.
All checks were successful
Deploy / deploy (push) Successful in 7m1s
All checks were successful
Deploy / deploy (push) Successful in 7m1s
This commit is contained in:
@@ -39,91 +39,105 @@ async function latinPair(
|
||||
];
|
||||
}
|
||||
|
||||
let siteOgFontsPromise: Promise<OgFont[]> | null = null;
|
||||
let rehberOgFontsPromise: Promise<OgFont[]> | null = null;
|
||||
|
||||
/** Ana sayfa OG: Bricolage (marka) + ClarityCity (gövde). */
|
||||
export async function loadSiteOgFonts(): Promise<OgFont[]> {
|
||||
const [bricolage, clarityLight, claritySemiBold] = await Promise.all([
|
||||
Promise.all([
|
||||
latinPair(
|
||||
"Bricolage Grotesque",
|
||||
300,
|
||||
"bricolage-grotesque-latin-300-normal.woff",
|
||||
"bricolage-grotesque-latin-ext-300-normal.woff",
|
||||
),
|
||||
latinPair(
|
||||
"Bricolage Grotesque",
|
||||
600,
|
||||
"bricolage-grotesque-latin-600-normal.woff",
|
||||
"bricolage-grotesque-latin-ext-600-normal.woff",
|
||||
),
|
||||
]).then((pairs) => pairs.flat()),
|
||||
loadFont("ClarityCity-Light.ttf"),
|
||||
loadFont("ClarityCity-SemiBold.ttf"),
|
||||
]);
|
||||
export function loadSiteOgFonts(): Promise<OgFont[]> {
|
||||
if (!siteOgFontsPromise) {
|
||||
siteOgFontsPromise = (async () => {
|
||||
const [bricolage, clarityLight, claritySemiBold] = await Promise.all([
|
||||
Promise.all([
|
||||
latinPair(
|
||||
"Bricolage Grotesque",
|
||||
300,
|
||||
"bricolage-grotesque-latin-300-normal.woff",
|
||||
"bricolage-grotesque-latin-ext-300-normal.woff",
|
||||
),
|
||||
latinPair(
|
||||
"Bricolage Grotesque",
|
||||
600,
|
||||
"bricolage-grotesque-latin-600-normal.woff",
|
||||
"bricolage-grotesque-latin-ext-600-normal.woff",
|
||||
),
|
||||
]).then((pairs) => pairs.flat()),
|
||||
loadFont("ClarityCity-Light.ttf"),
|
||||
loadFont("ClarityCity-SemiBold.ttf"),
|
||||
]);
|
||||
|
||||
return [
|
||||
...bricolage,
|
||||
{
|
||||
name: "Clarity City",
|
||||
data: clarityLight,
|
||||
weight: 300,
|
||||
style: "normal",
|
||||
},
|
||||
{
|
||||
name: "Clarity City",
|
||||
data: claritySemiBold,
|
||||
weight: 600,
|
||||
style: "normal",
|
||||
},
|
||||
];
|
||||
return [
|
||||
...bricolage,
|
||||
{
|
||||
name: "Clarity City",
|
||||
data: clarityLight,
|
||||
weight: 300,
|
||||
style: "normal" as const,
|
||||
},
|
||||
{
|
||||
name: "Clarity City",
|
||||
data: claritySemiBold,
|
||||
weight: 600,
|
||||
style: "normal" as const,
|
||||
},
|
||||
];
|
||||
})();
|
||||
}
|
||||
return siteOgFontsPromise;
|
||||
}
|
||||
|
||||
/** Rehber kapak OG: ClarityCity + Cal Sans + Bricolage. */
|
||||
export async function loadRehberOgFonts(): Promise<OgFont[]> {
|
||||
const [clarityBold, calSans, light, semiBold, extraBold] = await Promise.all([
|
||||
loadFont("ClarityCity-Bold.ttf"),
|
||||
latinPair(
|
||||
"Cal Sans",
|
||||
400,
|
||||
"cal-sans-latin-400-normal.woff",
|
||||
"cal-sans-latin-ext-400-normal.woff",
|
||||
),
|
||||
latinPair(
|
||||
"Bricolage Grotesque",
|
||||
300,
|
||||
"bricolage-grotesque-latin-300-normal.woff",
|
||||
"bricolage-grotesque-latin-ext-300-normal.woff",
|
||||
),
|
||||
latinPair(
|
||||
"Bricolage Grotesque",
|
||||
600,
|
||||
"bricolage-grotesque-latin-600-normal.woff",
|
||||
"bricolage-grotesque-latin-ext-600-normal.woff",
|
||||
),
|
||||
latinPair(
|
||||
"Bricolage Grotesque",
|
||||
800,
|
||||
"bricolage-grotesque-latin-800-normal.woff",
|
||||
"bricolage-grotesque-latin-ext-800-normal.woff",
|
||||
),
|
||||
]);
|
||||
/** Rehber / sayfa OG: ClarityCity + Cal Sans + Bricolage. */
|
||||
export function loadRehberOgFonts(): Promise<OgFont[]> {
|
||||
if (!rehberOgFontsPromise) {
|
||||
rehberOgFontsPromise = (async () => {
|
||||
const [clarityBold, calSans, light, semiBold, extraBold] =
|
||||
await Promise.all([
|
||||
loadFont("ClarityCity-Bold.ttf"),
|
||||
latinPair(
|
||||
"Cal Sans",
|
||||
400,
|
||||
"cal-sans-latin-400-normal.woff",
|
||||
"cal-sans-latin-ext-400-normal.woff",
|
||||
),
|
||||
latinPair(
|
||||
"Bricolage Grotesque",
|
||||
300,
|
||||
"bricolage-grotesque-latin-300-normal.woff",
|
||||
"bricolage-grotesque-latin-ext-300-normal.woff",
|
||||
),
|
||||
latinPair(
|
||||
"Bricolage Grotesque",
|
||||
600,
|
||||
"bricolage-grotesque-latin-600-normal.woff",
|
||||
"bricolage-grotesque-latin-ext-600-normal.woff",
|
||||
),
|
||||
latinPair(
|
||||
"Bricolage Grotesque",
|
||||
800,
|
||||
"bricolage-grotesque-latin-800-normal.woff",
|
||||
"bricolage-grotesque-latin-ext-800-normal.woff",
|
||||
),
|
||||
]);
|
||||
|
||||
// Sitede italic kullanılıyor; ayrı italic dosya yok — aynı kesimi italic olarak kaydet.
|
||||
const extraBoldItalic = extraBold.map((font) => ({
|
||||
...font,
|
||||
style: "italic" as const,
|
||||
}));
|
||||
// Sitede italic kullanılıyor; ayrı italic dosya yok — aynı kesimi italic olarak kaydet.
|
||||
const extraBoldItalic = extraBold.map((font) => ({
|
||||
...font,
|
||||
style: "italic" as const,
|
||||
}));
|
||||
|
||||
return [
|
||||
{
|
||||
name: "Clarity City",
|
||||
data: clarityBold,
|
||||
weight: 700,
|
||||
style: "normal",
|
||||
},
|
||||
...calSans,
|
||||
...light,
|
||||
...semiBold,
|
||||
...extraBold,
|
||||
...extraBoldItalic,
|
||||
];
|
||||
return [
|
||||
{
|
||||
name: "Clarity City",
|
||||
data: clarityBold,
|
||||
weight: 700,
|
||||
style: "normal" as const,
|
||||
},
|
||||
...calSans,
|
||||
...light,
|
||||
...semiBold,
|
||||
...extraBold,
|
||||
...extraBoldItalic,
|
||||
];
|
||||
})();
|
||||
}
|
||||
return rehberOgFontsPromise;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user