From 3b9af49ff7a3732149fcda4409a89309a00f98cf Mon Sep 17 00:00:00 2001 From: Katy DeCorah Date: Sun, 21 Apr 2024 18:49:25 -0400 Subject: [PATCH] Update font-call.ts --- components/font-call.ts | 52 ++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/components/font-call.ts b/components/font-call.ts index 2059140..64b0ecf 100644 --- a/components/font-call.ts +++ b/components/font-call.ts @@ -1,32 +1,6 @@ import { GeneratedData } from "./main-app"; import rtlSubsets from "../data/rtl.json"; -export default function fontCall({ - variants, - slug, - selectedVariant, - previewName, -}: { - variants: GeneratedData[number]["variants"]; - slug: string; - selectedVariant: string; - previewName: string; -}): string { - let fontCallString = slug; - - if (selectedVariant && selectedVariant !== "regular") { - fontCallString += fontCallSelectedVariant(selectedVariant); - } - // if font doesn't have regular variant, add subset to font call - if (!selectedVariant && !variants.includes("regular")) { - fontCallString += fontCallVariant(variants); - } - - fontCallString += `&text=${encodeURIComponent(previewName)}&display=swap`; - - return `https://fonts.googleapis.com/css2?family=${fontCallString}`; -} - export function fontCallVariant( variants: GeneratedData[number]["variants"], ): string { @@ -56,6 +30,32 @@ export function fontCallSelectedVariant(selectedVariant: string): string { return `:${variants.join(",")}`; } +export default function fontCall({ + variants, + slug, + selectedVariant, + previewName, +}: { + variants: GeneratedData[number]["variants"]; + slug: string; + selectedVariant: string; + previewName: string; +}): string { + let fontCallString = slug; + + if (selectedVariant && selectedVariant !== "regular") { + fontCallString += fontCallSelectedVariant(selectedVariant); + } + // if font doesn't have regular variant, add subset to font call + if (!selectedVariant && !variants.includes("regular")) { + fontCallString += fontCallVariant(variants); + } + + fontCallString += `&text=${encodeURIComponent(previewName)}&display=swap`; + + return `https://fonts.googleapis.com/css2?family=${fontCallString}`; +} + export function familyStyle({ family, selectedVariant,