Skip to content

Commit

Permalink
fix: fonts from cdn
Browse files Browse the repository at this point in the history
  • Loading branch information
desoindx committed Dec 5, 2024
1 parent 3f0b1f3 commit 8859802
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
12 changes: 9 additions & 3 deletions app/api/dynamics/comparateur/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ export async function GET(req: NextRequest) {
if (fonts.length === 0) {
fonts = (
await Promise.all([
getFont(new URL('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr/dist/fonts/Marianne-Regular.woff', import.meta.url)),
getFont(new URL('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr/dist/fonts/Marianne-Medium.woff', import.meta.url)),
getFont(new URL('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr/dist/fonts/Marianne-Bold.woff', import.meta.url)),
getFont(
new URL('https://cdn.jsdelivr.net/npm/@gouvfr/[email protected]/dist/fonts/Marianne-Regular.woff', import.meta.url)
),
getFont(
new URL('https://cdn.jsdelivr.net/npm/@gouvfr/[email protected]/dist/fonts/Marianne-Medium.woff', import.meta.url)
),
getFont(
new URL('https://cdn.jsdelivr.net/npm/@gouvfr/[email protected]/dist/fonts/Marianne-Bold.woff', import.meta.url)
),
])
).map((font, index) => ({
name: 'Marianne',
Expand Down
12 changes: 9 additions & 3 deletions app/api/dynamics/equivalents/[slug]/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ export async function GET(req: NextRequest, context: { params: Promise<{ slug: s
if (fonts.length === 0) {
fonts = (
await Promise.all([
getFont(new URL('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr/dist/fonts/Marianne-Regular.woff', import.meta.url)),
getFont(new URL('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr/dist/fonts/Marianne-Medium.woff', import.meta.url)),
getFont(new URL('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr/dist/fonts/Marianne-Bold.woff', import.meta.url)),
getFont(
new URL('https://cdn.jsdelivr.net/npm/@gouvfr/[email protected]/dist/fonts/Marianne-Regular.woff', import.meta.url)
),
getFont(
new URL('https://cdn.jsdelivr.net/npm/@gouvfr/[email protected]/dist/fonts/Marianne-Medium.woff', import.meta.url)
),
getFont(
new URL('https://cdn.jsdelivr.net/npm/@gouvfr/[email protected]/dist/fonts/Marianne-Bold.woff', import.meta.url)
),
])
).map((font, index) => ({
name: 'Marianne',
Expand Down
6 changes: 3 additions & 3 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export const metadata: Metadata = {
}

const fonts = [
'https://cdn.jsdelivr.net/npm/@gouvfr/dsfr/dist/fonts/Marianne-Regular.woff2',
'https://cdn.jsdelivr.net/npm/@gouvfr/dsfr/dist/fonts/Marianne-Medium.woff2',
'https://cdn.jsdelivr.net/npm/@gouvfr/dsfr/dist/fonts/Marianne-Bold.woff2',
'https://cdn.jsdelivr.net/npm/@gouvfr/dsfr@12.1.1/dist/fonts/Marianne-Regular.woff2',
'https://cdn.jsdelivr.net/npm/@gouvfr/dsfr@12.1.1/dist/fonts/Marianne-Medium.woff2',
'https://cdn.jsdelivr.net/npm/@gouvfr/dsfr@12.1.1/dist/fonts/Marianne-Bold.woff2',
]

const RootLayout = ({ children }: { children: React.ReactNode }) => {
Expand Down
12 changes: 6 additions & 6 deletions src/utils/fonts.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@font-face {
font-family: 'Marianne';
src:
url('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr/dist/fonts/Marianne-Regular.woff2') format('woff2'),
url('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr/dist/fonts/Marianne-Regular.woff') format('woff');
url('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr@12.1.1/dist/fonts/Marianne-Regular.woff2') format('woff2'),
url('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr@12.1.1/dist/fonts/Marianne-Regular.woff') format('woff');
font-weight: 400;
font-style: normal;
font-display: swap;
Expand All @@ -11,8 +11,8 @@
@font-face {
font-family: 'Marianne';
src:
url('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr/dist/fonts/Marianne-Medium.woff2') format('woff2'),
url('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr/dist/fonts/Marianne-Medium.woff') format('woff');
url('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr@12.1.1/dist/fonts/Marianne-Medium.woff2') format('woff2'),
url('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr@12.1.1/dist/fonts/Marianne-Medium.woff') format('woff');
font-weight: 500;
font-style: normal;
font-display: swap;
Expand All @@ -21,8 +21,8 @@
@font-face {
font-family: 'Marianne';
src:
url('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr/dist/fonts/Marianne-Bold.woff2') format('woff2'),
url('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr/dist/fonts/Marianne-Bold.woff') format('woff');
url('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr@12.1.1/dist/fonts/Marianne-Bold.woff2') format('woff2'),
url('https://cdn.jsdelivr.net/npm/@gouvfr/dsfr@12.1.1/dist/fonts/Marianne-Bold.woff') format('woff');
font-weight: 700;
font-style: normal;
font-display: swap;
Expand Down

0 comments on commit 8859802

Please sign in to comment.