Skip to content

Commit e5a953e

Browse files
committed
refactor(docs): not found page & simplify folder structure
1 parent b934f4c commit e5a953e

16 files changed

+167
-67
lines changed

docs/next.config.mjs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,6 @@ import nextra from "nextra";
44
const nextConfig = {
55
// Configure `pageExtensions` to include markdown and MDX files
66
pageExtensions: ["js", "jsx", "md", "mdx", "ts", "tsx"],
7-
redirects: () => {
8-
return [
9-
{
10-
source: "/privacy-policy",
11-
destination: "/docs/legal/privacy-policy",
12-
permanent: true,
13-
},
14-
{
15-
source: "/terms-and-conditions",
16-
destination: "/docs/legal/terms-and-conditions",
17-
permanent: true,
18-
},
19-
];
20-
},
217
};
228

239
const withNextra = nextra({

docs/public/favicon.ico

50.4 KB
Binary file not shown.

docs/src/app/not-found.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Button } from "@/components/Button";
2+
import Link from "next/link";
3+
4+
const NotFoundPage = () => {
5+
return (
6+
<div className="flex h-screen w-full flex-col items-center justify-center gap-6 px-4">
7+
<div className="space-y-2 text-center">
8+
<h1 className="text-9xl font-bold">404</h1>
9+
<p className="text-2xl font-medium">
10+
Oops, the page you&rsquo;re looking for cannot be found.
11+
</p>
12+
</div>
13+
<div className="flex gap-4">
14+
<Link href="/" legacyBehavior>
15+
<Button as="a">Landing page</Button>
16+
</Link>
17+
<Link href="/docs" legacyBehavior>
18+
<Button as="a">Documentation</Button>
19+
</Link>
20+
</div>
21+
</div>
22+
);
23+
};
24+
25+
export default NotFoundPage;

docs/src/app/page.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ const LandingPage = () => {
6363

6464
<div className="rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-50">
6565
<h2 className="mb-3 text-2xl font-semibold">Legal</h2>
66-
<a href="/privacy-policy" className="px-5" target="_blank">
66+
<a
67+
href="/docs/privacy-policy"
68+
className="px-5"
69+
target="_blank"
70+
>
6771
<h3 className="group text-sm font-semibold">
6872
Privacy policy
6973
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
@@ -72,7 +76,7 @@ const LandingPage = () => {
7276
</h3>
7377
</a>
7478
<a
75-
href="/terms-and-conditions"
79+
href="/docs/terms-and-conditions"
7680
className="px-5"
7781
target="_blank"
7882
>

docs/src/app/sitemap.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { MetadataRoute } from "next";
2+
3+
const HOMEPAGE = "https://metro-now.vercel.app";
4+
5+
const pages = [
6+
"/",
7+
"/docs",
8+
"/docs/backend",
9+
"/docs/privacy-policy",
10+
"/docs/rest-api",
11+
"/docs/terms-and-conditions",
12+
] as const satisfies string[];
13+
14+
type PriorityByPage = {
15+
[key in (typeof pages)[number]]?: number;
16+
};
17+
18+
const priorityByPage: PriorityByPage = {
19+
"/": 1,
20+
};
21+
22+
const sitemap = (): MetadataRoute.Sitemap => {
23+
return pages.map((url) => ({
24+
url: `${HOMEPAGE}${String(url)}`,
25+
lastModified: new Date(),
26+
priority: priorityByPage[url] ?? 0.5,
27+
}));
28+
};
29+
30+
export default sitemap;

docs/src/components/Button.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { ElementType, ComponentPropsWithoutRef } from "react";
2+
3+
type Props = Exclude<ComponentPropsWithoutRef<"button">, "className"> & {
4+
as: ElementType;
5+
};
6+
7+
const Button = (props: Props) => {
8+
const { children, className, as: Component = "button", ...rest } = props;
9+
10+
return (
11+
<Component
12+
className="inline-flex h-10 items-center justify-center rounded-md bg-gray-900 px-6 text-sm font-medium text-gray-50 shadow transition-colors hover:bg-gray-900/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-gray-950"
13+
{...rest}
14+
>
15+
{children}
16+
</Component>
17+
);
18+
};
19+
20+
export { Button };

docs/src/pages/_meta.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@
33
"title": "Docs",
44
"type": "page"
55
},
6+
7+
"api": {
8+
"title": "API",
9+
"type": "page",
10+
"href": "/docs/rest-api"
11+
},
612
"legal": {
713
"title": "Legal",
814
"type": "menu",
915
"items": {
1016
"about": {
1117
"title": "Privacy policy",
12-
"href": "/docs/legal/privacy-policy"
18+
"href": "/docs/privacy-policy"
1319
},
1420
"contact": {
1521
"title": "Terms & conditions",
16-
"href": "/docs/legal/terms-and-conditions"
22+
"href": "/docs/terms-and-conditions"
1723
}
1824
}
1925
}

docs/src/pages/docs/_meta.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
},
66
"rest-api": "REST API",
77
"backend": "Backend",
8-
"legal": "Legal"
8+
"-- Legal": {
9+
"type": "separator",
10+
"title": "Legal"
11+
}
912
}

docs/src/pages/docs/backend.mdx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Backend
2+
3+
[source code](https://github.com/krystxf/metro-now/tree/main/backend)
4+
5+
Lightweight backend that provides data from [Golemio API](https://api.golemio.cz/pid/docs/openapi/#/%F0%9F%9A%8F%20PID%20Departure%20Boards/get_pid_departureboards).
6+
7+
## Technologies
8+
9+
### V1
10+
11+
built with [Bun](https://github.com/oven-sh/bun)
12+
13+
- [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) endpoint
14+
15+
**Setup**
16+
17+
```bash
18+
# Clone the repository
19+
git clone https://github.com/krystxf/metro-now.git
20+
21+
# Open the backend directory
22+
cd metro-now/backend/v1
23+
24+
# Install dependencies
25+
bun install
26+
27+
# Create a .env file
28+
cp .env.example .env
29+
30+
# Edit the .env files with your own values
31+
32+
# Start the backend
33+
bun start
34+
```
35+
36+
### V2
37+
38+
built with [Express.js](https://expressjs.com/)
39+
40+
- REST endpoint
41+
**Setup**
42+
43+
```bash
44+
# Clone the repository
45+
git clone https://github.com/krystxf/metro-now.git
46+
47+
# Open the backend directory
48+
cd metro-now/backend/v2
49+
50+
# Install dependencies
51+
pnpm install
52+
53+
# Create a .env file
54+
cp .env.example .env
55+
56+
# Edit the .env files with your own values
57+
58+
# Start the backend
59+
pnpm run dev
60+
```

docs/src/pages/docs/backend/_meta.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/src/pages/docs/backend/index.mdx

Lines changed: 0 additions & 14 deletions
This file was deleted.

docs/src/pages/docs/backend/installation.mdx

Lines changed: 0 additions & 30 deletions
This file was deleted.

docs/src/pages/docs/rest-api.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Backend gets data from [Golemio API](https://api.golemio.cz/pid/docs/openapi/) c
44

55
## Metro departures
66

7-
Wrapper for [Golemio departures API](https://api.golemio.cz/pid/docs/openapi/#/%F0%9F%9A%8F%20PID%20Departure%20Boards/get_pid_departureboards)
7+
[Golemio departures API](https://api.golemio.cz/pid/docs/openapi/#/%F0%9F%9A%8F%20PID%20Departure%20Boards/get_pid_departureboards)
88

99
```http
1010
GET https://api.metronow.dev/v1/metro/v1/metro/departures

docs/theme.config.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,22 @@ import React from "react";
22

33
const themeConfig = {
44
logo: <strong>🚇 metro-now</strong>,
5+
docsRepositoryBase: "https://github.com/krystxf/metro-now/tree/main/docs",
56
project: {
67
link: "https://github.com/krystxf/metro-now",
78
},
9+
editLink: {
10+
text: "Edit this page on GitHub →",
11+
},
12+
footer: {
13+
text: (
14+
<div className="flex w-full sm:items-start pt-6">
15+
<p className="text-xs">
16+
© {new Date().getFullYear()} metro-now
17+
</p>
18+
</div>
19+
),
20+
},
821
};
922

1023
export default themeConfig;

0 commit comments

Comments
 (0)