Skip to content

Commit 6ab0ec2

Browse files
authored
Merge pull request #438 from api-platform/staging
MEP
2 parents d3ccbce + 74b2648 commit 6ab0ec2

File tree

4 files changed

+34
-13
lines changed

4 files changed

+34
-13
lines changed

pwa/app/(common)/layout.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import "styles/common.css";
22
import "@docsearch/css";
3-
import { Poppins } from "next/font/google";
3+
import { Poppins, Fira_Mono } from "next/font/google";
44
import Layout from "components/layout/Layout";
55
import { Metadata } from "next";
66
import { getRootUrl } from "utils";
@@ -12,6 +12,13 @@ const poppins = Poppins({
1212
subsets: ["latin", "latin-ext"],
1313
});
1414

15+
const fira = Fira_Mono({
16+
variable: "--font-fira",
17+
display: "swap",
18+
weight: ["400", "500", "700"],
19+
subsets: ["latin", "latin-ext"],
20+
});
21+
1522
export async function generateMetadata(): Promise<Metadata> {
1623
const dictionary = await import(`data/meta.json`);
1724

@@ -56,7 +63,10 @@ function RootLayout({
5663
children: React.ReactNode;
5764
}) {
5865
return (
59-
<html lang="en" className={`${poppins.variable} w-full light`}>
66+
<html
67+
lang="en"
68+
className={`${poppins.variable} ${fira.variable} w-full light`}
69+
>
6070
<body className="bg-white dark:bg-blue-black">
6171
<Layout>{children}</Layout>
6272
</body>

pwa/common.tailwind.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ module.exports = {
6666
},
6767
fontFamily: {
6868
title: ["var(--font-poppins)"],
69+
mono: ["var(--font-fira)"],
6970
},
7071
maxWidth: {
7172
"8xl": "90rem",

pwa/middleware.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,24 @@ import { match as matchLocale } from "@formatjs/intl-localematcher";
44
import Negotiator from "negotiator";
55

66
function getLocale(request: NextRequest): string | undefined {
7-
// Negotiator expects plain object so we need to transform headers
8-
const negotiatorHeaders: Record<string, string> = {};
9-
request.headers.forEach((value, key) => (negotiatorHeaders[key] = value));
7+
try {
8+
// Negotiator expects plain object so we need to transform headers
9+
const negotiatorHeaders: Record<string, string> = {};
10+
request.headers.forEach((value, key) => (negotiatorHeaders[key] = value));
1011

11-
// Use negotiator and intl-localematcher to get best locale
12-
const languages = new Negotiator({ headers: negotiatorHeaders }).languages();
13-
const locales = [...i18n.locales];
14-
const locale = matchLocale(languages, locales, i18n.defaultLocale);
15-
return ([...i18n.locales] as string[]).includes(locale)
16-
? locale
17-
: i18n.defaultLocale;
12+
// Use negotiator and intl-localematcher to get best locale
13+
const languages = new Negotiator({
14+
headers: negotiatorHeaders,
15+
}).languages();
16+
const locales = [...i18n.locales];
17+
const locale = matchLocale(languages, locales, i18n.defaultLocale);
18+
return ([...i18n.locales] as string[]).includes(locale)
19+
? locale
20+
: i18n.defaultLocale;
21+
} catch (e) {
22+
console.error(e);
23+
return i18n.defaultLocale;
24+
}
1825
}
1926

2027
export async function middleware(request: NextRequest) {

pwa/styles/common.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
@apply hidden;
4141
}
4242
.doc pre {
43-
@apply text-sm whitespace-pre-wrap leading-relaxed !bg-gray-100 dark:!bg-blue-darkest rounded-2xl mt-2 mb-4 overflow-x-auto;
43+
@apply font-mono text-sm whitespace-pre-wrap leading-relaxed !bg-gray-100 dark:!bg-blue-darkest rounded-2xl mt-2 mb-4 overflow-x-auto;
4444
}
4545
.doc pre > code > pre {
4646
@apply p-0 m-0 rounded-none !bg-transparent;
@@ -54,6 +54,9 @@
5454
.doc a {
5555
@apply text-blue;
5656
}
57+
.doc code span.line:not(:last-of-type):after {
58+
content: "\200B"; /* useful to set correct height on empty lines */
59+
}
5760
}
5861

5962
@layer utilities {

0 commit comments

Comments
 (0)