Skip to content

Commit b6d1097

Browse files
author
iexitdev
committed
Prefix docs routes with react-native
1 parent fae06b3 commit b6d1097

8 files changed

Lines changed: 56 additions & 38 deletions

File tree

apps/site/astro.config.mjs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { chartKitMarkdownPatches } from "./src/lib/starlight-markdown-patches.mj
88
import tailwindcss from "@tailwindcss/vite";
99

1010
const repositoryUrl = "https://github.com/indiespirit/react-native-chart-kit";
11+
const docsSlug = (slug) => `docs/react-native/${slug}`;
1112
const packageSource = (packagePath) =>
1213
fileURLToPath(new URL(`../../packages/${packagePath}`, import.meta.url));
1314
const nodeModuleSource = (packagePath) =>
@@ -78,36 +79,36 @@ export default defineConfig({
7879
{
7980
label: "Start",
8081
items: [
81-
{ slug: "docs/getting-started/installation" },
82-
{ slug: "docs/getting-started/contributing" }
82+
{ slug: docsSlug("getting-started/installation") },
83+
{ slug: docsSlug("getting-started/contributing") }
8384
]
8485
},
8586
{
8687
label: "Charts",
8788
items: [
88-
{ slug: "docs/charts/line" },
89-
{ slug: "docs/charts/area" },
90-
{ slug: "docs/charts/bar" },
91-
{ slug: "docs/charts/pie" },
92-
{ slug: "docs/charts/donut" },
93-
{ slug: "docs/charts/progress" },
94-
{ slug: "docs/charts/contribution-heatmap" }
89+
{ slug: docsSlug("charts/line") },
90+
{ slug: docsSlug("charts/area") },
91+
{ slug: docsSlug("charts/bar") },
92+
{ slug: docsSlug("charts/pie") },
93+
{ slug: docsSlug("charts/donut") },
94+
{ slug: docsSlug("charts/progress") },
95+
{ slug: docsSlug("charts/contribution-heatmap") }
9596
]
9697
},
9798
{
9899
label: "Guides",
99100
items: [
100-
{ slug: "docs/charts/themes" },
101-
{ slug: "docs/charts/accessibility" },
102-
{ slug: "docs/troubleshooting" },
103-
{ slug: "docs/recipes" }
101+
{ slug: docsSlug("charts/themes") },
102+
{ slug: docsSlug("charts/accessibility") },
103+
{ slug: docsSlug("troubleshooting") },
104+
{ slug: docsSlug("recipes") }
104105
]
105106
},
106107
{
107108
label: "Migration",
108109
items: [
109-
{ slug: "docs/migration/from-v1" },
110-
{ slug: "docs/migration/prop-mapping" }
110+
{ slug: docsSlug("migration/from-v1") },
111+
{ slug: docsSlug("migration/prop-mapping") }
111112
]
112113
}
113114
],

apps/site/src/components/ChartKitFeatures.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const features = [
5555
interactive.
5656
</p>
5757
<a
58-
href="/docs/getting-started/installation"
58+
href="/docs/react-native/getting-started/installation"
5959
class="mt-8 inline-flex h-10 items-center justify-center rounded-full border border-white/15 px-5 text-sm font-semibold tracking-[-0.01em] text-white/78 transition-colors hover:border-white/28 hover:text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-white/45 [html[data-theme='light']_&]:border-black/15 [html[data-theme='light']_&]:text-black/70 [html[data-theme='light']_&]:hover:border-black/28 [html[data-theme='light']_&]:hover:text-black [html[data-theme='light']_&]:focus-visible:outline-black/40"
6060
>
6161
Read docs

apps/site/src/components/ChartsSupported.tsx

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,38 @@ type ChartType = {
2525

2626
type ThemeMode = "dark" | "light";
2727

28+
const docsBaseHref = "/docs/react-native";
29+
2830
const chartTypes: ChartType[] = [
29-
{ docsHref: "/docs/charts/line/", kind: "line", title: "Line Chart" },
30-
{ docsHref: "/docs/charts/area/", kind: "area", title: "Area Chart" },
31-
{ docsHref: "/docs/charts/bar/", kind: "bar", title: "Bar Chart" },
3231
{
33-
docsHref: "/docs/charts/bar/#stacked-bars",
32+
docsHref: `${docsBaseHref}/charts/line/`,
33+
kind: "line",
34+
title: "Line Chart"
35+
},
36+
{
37+
docsHref: `${docsBaseHref}/charts/area/`,
38+
kind: "area",
39+
title: "Area Chart"
40+
},
41+
{ docsHref: `${docsBaseHref}/charts/bar/`, kind: "bar", title: "Bar Chart" },
42+
{
43+
docsHref: `${docsBaseHref}/charts/bar/#stacked-bars`,
3444
kind: "stackedBar",
3545
title: "Stacked Bar Chart"
3646
},
37-
{ docsHref: "/docs/charts/pie/", kind: "pie", title: "Pie Chart" },
38-
{ docsHref: "/docs/charts/donut/", kind: "donut", title: "Donut Chart" },
47+
{ docsHref: `${docsBaseHref}/charts/pie/`, kind: "pie", title: "Pie Chart" },
48+
{
49+
docsHref: `${docsBaseHref}/charts/donut/`,
50+
kind: "donut",
51+
title: "Donut Chart"
52+
},
3953
{
40-
docsHref: "/docs/charts/progress/",
54+
docsHref: `${docsBaseHref}/charts/progress/`,
4155
kind: "progress",
4256
title: "Progress Circle"
4357
},
4458
{
45-
docsHref: "/docs/charts/contribution-heatmap/",
59+
docsHref: `${docsBaseHref}/charts/contribution-heatmap/`,
4660
kind: "heatmap",
4761
title: "Contribution Heatmap"
4862
},
@@ -1040,7 +1054,7 @@ export default function ChartsSupported() {
10401054

10411055
<div className="mt-7 flex justify-center">
10421056
<a
1043-
href="/docs/charts/line"
1057+
href={`${docsBaseHref}/charts/line`}
10441058
className="inline-flex h-10 items-center justify-center rounded-full border border-white/15 px-5 text-sm font-semibold tracking-[-0.01em] text-white/78 transition-colors hover:border-white/28 hover:text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-white/45 [html[data-theme='light']_&]:border-black/15 [html[data-theme='light']_&]:text-black/70 [html[data-theme='light']_&]:hover:border-black/28 [html[data-theme='light']_&]:hover:text-black [html[data-theme='light']_&]:focus-visible:outline-black/40"
10451059
>
10461060
Read docs

apps/site/src/components/Footer.astro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const footerGroups = [
1818
label: "Pricing"
1919
},
2020
{
21-
href: "/docs",
21+
href: "/docs/react-native",
2222
label: "Docs"
2323
}
2424
]
@@ -27,15 +27,15 @@ const footerGroups = [
2727
title: "Company",
2828
links: [
2929
{
30-
href: "/docs/migration/from-v1",
30+
href: "/docs/react-native/migration/from-v1",
3131
label: "Migration"
3232
},
3333
{
34-
href: "/docs/recipes",
34+
href: "/docs/react-native/recipes",
3535
label: "Recipes"
3636
},
3737
{
38-
href: "/docs/troubleshooting",
38+
href: "/docs/react-native/troubleshooting",
3939
label: "Support"
4040
}
4141
]

apps/site/src/components/Header.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const navigationLinks = [
1515
label: "Pricing"
1616
},
1717
{
18-
href: "/docs",
18+
href: "/docs/react-native",
1919
label: "Docs"
2020
}
2121
];

apps/site/src/components/Pricing.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const plans = [
1111
cadence: "",
1212
description: "For hobby apps and simple dashboards.",
1313
cta: "Get started",
14-
href: "/docs/getting-started/installation",
14+
href: "/docs/react-native/getting-started/installation",
1515
featured: false,
1616
features: [
1717
"Basic charts",
@@ -27,7 +27,7 @@ const plans = [
2727
cadence: "/ dev / year",
2828
description: "For production apps.",
2929
cta: "Start Pro",
30-
href: "/docs/getting-started/installation",
30+
href: "/docs/react-native/getting-started/installation",
3131
featured: true,
3232
features: [
3333
"Smart layout engine",

apps/site/src/content.config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ const publicDocs = [
1010
"recipes/**/*.md",
1111
"troubleshooting.md"
1212
];
13+
const docsRoutePrefix = "docs/react-native";
1314

1415
const getRouteId = (entry: string) => {
1516
if (entry === "README.md") {
16-
return "docs";
17+
return docsRoutePrefix;
1718
}
1819

1920
if (entry.endsWith("/README.md")) {
20-
return `docs/${entry.slice(0, -"/README.md".length)}`;
21+
return `${docsRoutePrefix}/${entry.slice(0, -"/README.md".length)}`;
2122
}
2223

23-
return `docs/${entry.replace(/\.mdx?$/, "")}`;
24+
return `${docsRoutePrefix}/${entry.replace(/\.mdx?$/, "")}`;
2425
};
2526

2627
export const collections = {

apps/site/src/lib/remark-strip-duplicate-title.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,18 @@ const getDocsEntryPath = (file) => {
4040
return undefined;
4141
};
4242

43+
const docsRoutePrefix = "/docs/react-native";
44+
4345
const getDocsRoute = (docsPath) => {
4446
if (docsPath === "README.md") {
45-
return "/docs/";
47+
return `${docsRoutePrefix}/`;
4648
}
4749

4850
if (docsPath.endsWith("/README.md")) {
49-
return `/docs/${docsPath.slice(0, -"/README.md".length)}/`;
51+
return `${docsRoutePrefix}/${docsPath.slice(0, -"/README.md".length)}/`;
5052
}
5153

52-
return `/docs/${docsPath.replace(/\.mdx?$/, "")}/`;
54+
return `${docsRoutePrefix}/${docsPath.replace(/\.mdx?$/, "")}/`;
5355
};
5456

5557
const rewriteMarkdownLinks = (tree, file) => {

0 commit comments

Comments
 (0)