Skip to content

Commit a94ada3

Browse files
committed
🔖 Version bump
Fix links to account for prefix
1 parent 7a9fa70 commit a94ada3

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "example",
3-
"version": "1.0.0",
3+
"version": "1.0.2",
44
"main": "index.js",
55
"author": "Committed <[email protected]>",
66
"license": "MIT",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@committed/gatsby-theme-docs-workspace",
33
"private": true,
4-
"version": "1.0.1",
4+
"version": "1.0.2",
55
"main": "index.js",
66
"license": "MIT",
77
"scripts": {

theme/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@committed/gatsby-theme-docs",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"main": "index.js",
55
"author": "Committed <[email protected]>",
66
"license": "MIT",

theme/src/components/Layout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ThemeProvider, CodeStyle, Container, Box } from '@committed/components'
1414
export interface LayoutProps extends SEOProps {}
1515
export type LocationContextProps = {
1616
pathname: string
17+
prefix: string
1718
}
1819
export const LocationContext = React.createContext<
1920
Partial<LocationContextProps>
@@ -54,7 +55,7 @@ export const Layout = ({ children, location = {}, title, ...props }) => {
5455
const treeData = calculateTreeData(sidebar, data.allDocs.edges)
5556
const flattenedData = flattenTree(treeData)
5657
return (
57-
<LocationContext.Provider value={location}>
58+
<LocationContext.Provider value={{ prefix, ...location }}>
5859
<ThemeProvider
5960
fonts={{
6061
display: {

theme/src/components/Link.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@ const LocalLink: React.FC<LinkProps> = ({
1313
...props
1414
}: LinkProps) => (
1515
<LocationContext.Consumer>
16-
{({ pathname }) => {
16+
{({ prefix, pathname }) => {
1717
let to = href
18+
let base = pathname
19+
// account for pathname including prefix
20+
if (prefix !== '/' && pathname.startsWith(prefix)) {
21+
base = pathname.substring(prefix.length)
22+
}
1823
if (isInPage(href)) {
19-
to = pathname + href
24+
to = base + href
2025
} else if (isRelative(href)) {
21-
to = pathname.replace(/\/[^\/]*$/, `/${href}`)
26+
to = base.replace(/\/[^\/]*$/, `/${href}`)
2227
}
2328
return (
2429
<RawLink variant={variant} onClick={() => navigate(to)} {...props} />

0 commit comments

Comments
 (0)