Skip to content

Commit

Permalink
Merge pull request #438 from api-platform/staging
Browse files Browse the repository at this point in the history
MEP
  • Loading branch information
ginifizz authored Jul 20, 2023
2 parents d3ccbce + 74b2648 commit 6ab0ec2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 13 deletions.
14 changes: 12 additions & 2 deletions pwa/app/(common)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "styles/common.css";
import "@docsearch/css";
import { Poppins } from "next/font/google";
import { Poppins, Fira_Mono } from "next/font/google";
import Layout from "components/layout/Layout";
import { Metadata } from "next";
import { getRootUrl } from "utils";
Expand All @@ -12,6 +12,13 @@ const poppins = Poppins({
subsets: ["latin", "latin-ext"],
});

const fira = Fira_Mono({
variable: "--font-fira",
display: "swap",
weight: ["400", "500", "700"],
subsets: ["latin", "latin-ext"],
});

export async function generateMetadata(): Promise<Metadata> {
const dictionary = await import(`data/meta.json`);

Expand Down Expand Up @@ -56,7 +63,10 @@ function RootLayout({
children: React.ReactNode;
}) {
return (
<html lang="en" className={`${poppins.variable} w-full light`}>
<html
lang="en"
className={`${poppins.variable} ${fira.variable} w-full light`}
>
<body className="bg-white dark:bg-blue-black">
<Layout>{children}</Layout>
</body>
Expand Down
1 change: 1 addition & 0 deletions pwa/common.tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ module.exports = {
},
fontFamily: {
title: ["var(--font-poppins)"],
mono: ["var(--font-fira)"],
},
maxWidth: {
"8xl": "90rem",
Expand Down
27 changes: 17 additions & 10 deletions pwa/middleware.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@ import { match as matchLocale } from "@formatjs/intl-localematcher";
import Negotiator from "negotiator";

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

// Use negotiator and intl-localematcher to get best locale
const languages = new Negotiator({ headers: negotiatorHeaders }).languages();
const locales = [...i18n.locales];
const locale = matchLocale(languages, locales, i18n.defaultLocale);
return ([...i18n.locales] as string[]).includes(locale)
? locale
: i18n.defaultLocale;
// Use negotiator and intl-localematcher to get best locale
const languages = new Negotiator({
headers: negotiatorHeaders,
}).languages();
const locales = [...i18n.locales];
const locale = matchLocale(languages, locales, i18n.defaultLocale);
return ([...i18n.locales] as string[]).includes(locale)
? locale
: i18n.defaultLocale;
} catch (e) {
console.error(e);
return i18n.defaultLocale;
}
}

export async function middleware(request: NextRequest) {
Expand Down
5 changes: 4 additions & 1 deletion pwa/styles/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
@apply hidden;
}
.doc pre {
@apply text-sm whitespace-pre-wrap leading-relaxed !bg-gray-100 dark:!bg-blue-darkest rounded-2xl mt-2 mb-4 overflow-x-auto;
@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;
}
.doc pre > code > pre {
@apply p-0 m-0 rounded-none !bg-transparent;
Expand All @@ -54,6 +54,9 @@
.doc a {
@apply text-blue;
}
.doc code span.line:not(:last-of-type):after {
content: "\200B"; /* useful to set correct height on empty lines */
}
}

@layer utilities {
Expand Down

0 comments on commit 6ab0ec2

Please sign in to comment.