Skip to content

Commit e6b37b0

Browse files
committed
feat: add featured pictures for patterns
1 parent 4fc50dc commit e6b37b0

File tree

8 files changed

+54
-1
lines changed

8 files changed

+54
-1
lines changed

app/_components/pattern-preview.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use client'
2+
3+
import Image from "next/image"
4+
import { usePathname } from "next/navigation"
5+
6+
export const PatternPreview = ({ alt }: { alt: string }) => {
7+
const pathname = usePathname()
8+
const segments = pathname.split('/')
9+
const patternName = segments[segments.length - 1]
10+
11+
return (
12+
<div className="pattern-preview">
13+
<Image
14+
src={`/covers/patterns/${patternName}.png`}
15+
alt={alt || `Example of ${patternName} pattern`}
16+
width={800}
17+
height={400}
18+
priority
19+
unoptimized
20+
/>
21+
</div>
22+
)
23+
}

content/en/patterns/forms/button.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22
summary: "Trigger actions and submit forms"
33
description: "Learn how to implement accessible and user-friendly buttons in your web applications. Discover best practices for button design, states, accessibility, and implementation with code examples and guidelines."
44
icon: MousePointerClick
5+
ogImage: /covers/patterns/button.png
56
status: complete
67
---
78

89
import { BrowserSupport } from "@app/_components/browser-support";
910
import { BuildEffort } from "@app/_components/build-effort";
1011
import { FaqStructuredData } from "@app/_components/faq-structured-data";
12+
import { PatternPreview } from "@app/_components/pattern-preview";
1113

1214
# Button
1315

16+
<PatternPreview
17+
alt="Example of a primary button UI pattern showing a Continue button in
18+
action"
19+
/>
20+
1421
## Overview
1522

1623
**Buttons** are interactive elements that trigger actions or events when clicked or interacted with.

content/en/patterns/navigation/pagination.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@
22
summary: "Navigate through multiple pages of content"
33
description: "Master pagination implementation in web applications. Learn best practices for building accessible, user-friendly page navigation with clear guidelines for design, accessibility, and performance."
44
icon: Route
5+
ogImage: /covers/patterns/pagination.png
56
status: complete
67
---
78

89
import { BrowserSupport } from "@app/_components/browser-support";
910
import { BuildEffort } from "@app/_components/build-effort";
1011
import { FaqStructuredData } from "@app/_components/faq-structured-data";
12+
import { PatternPreview } from "@app/_components/pattern-preview";
1113
import { StepsPagination } from "@app/_components/seo/steps-pagination.tsx";
1214

1315
<StepsPagination />
1416

1517
# Pagination
1618

19+
<PatternPreview />
20+
1721
## Overview
1822

1923
**[Pagination](/glossary/pagination)** is a navigation pattern used to divide large collections of content into manageable chunks or pages.

middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ export { middleware } from 'nextra/locales'
33
export const config = {
44
// Matcher ignoring `/_next/` and `/api/`
55
matcher: [
6-
'/((?!api/mdx|api/email|api/patterns/random|api/og|_next/static|_next/image|favicon.ico|robots.txt|og/opengraph-image.png|twitter-image|sitemap.xml|6ba7b811-9dad-11d1-80b4.txt|43mg4ybv6sxxanu24g7dngawd9up5w93.txt|apple-icon.png|manifest|_pagefind|examples).*)'
6+
'/((?!api/mdx|api/email|api/patterns/random|api/og|_next/static|_next/image|favicon.ico|robots.txt|og/opengraph-image.png|covers|twitter-image|sitemap.xml|6ba7b811-9dad-11d1-80b4.txt|43mg4ybv6sxxanu24g7dngawd9up5w93.txt|apple-icon.png|manifest|_pagefind|examples).*)'
77
]
88
}

next.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ const nextConfig = withBundleAnalyzer(
4141
source: '/patterns',
4242
destination: '/patterns/getting-started',
4343
statusCode: 302
44+
},
45+
{
46+
source: '/patterns/docs/navigation/breadcrumb',
47+
destination: '/patterns/navigation/breadcrumb',
48+
statusCode: 302
4449
}
4550
],
4651
async rewrites() {

public/covers/patterns/button.png

8.76 KB
Loading

public/covers/patterns/pagination.png

7.17 KB
Loading

styles/globals.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,17 @@ body {
5858
.nextra-content .contains-task-list li {
5959
@apply my-2;
6060
}
61+
62+
.pattern-preview {
63+
display: flex;
64+
justify-content: center;
65+
margin: 1rem 0;
66+
padding: 1rem 0;
67+
border-radius: 8px;
68+
}
69+
70+
.pattern-preview img {
71+
max-width: 600px;
72+
height: auto;
73+
width: 100%;
74+
}

0 commit comments

Comments
 (0)