@primer/doctocat-nextjs 0.0.2-rc.1da8f9a → 0.0.2-rc.cdbd6bf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,4 @@
|
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- [#4](https://github.com/primer/doctocat-nextjs/pull/4) [`4f28982`](https://github.com/primer/doctocat-nextjs/commit/4f28982e327e75f199f28fad987f1e827deafeb2) Thanks [@joseph-lozano](https://github.com/joseph-lozano)! - Wrap links with Next's Link component
|
|
8
|
-
|
|
9
7
|
- [#2](https://github.com/primer/doctocat-nextjs/pull/2) [`2742b32`](https://github.com/primer/doctocat-nextjs/commit/2742b3214e7a53416d23f0459dc389f7c22cf5a1) Thanks [@rezrah](https://github.com/rezrah)! - Remove code blocks stylesheet, now merged into global.css
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import {Card, Grid} from '@primer/react-brand'
|
|
3
3
|
import {Folder, MdxFile} from 'nextra'
|
|
4
|
+
import {useRouter} from 'next/router'
|
|
4
5
|
|
|
5
6
|
import styles from './IndexCards.module.css'
|
|
6
|
-
import Link from 'next/link'
|
|
7
7
|
|
|
8
8
|
type IndexCardsProps = {
|
|
9
9
|
route: string
|
|
@@ -22,6 +22,7 @@ type DocsItem = (MdxFile | FolderWithoutChildren) & {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export function IndexCards({route, folderData}: IndexCardsProps) {
|
|
25
|
+
const {basePath} = useRouter()
|
|
25
26
|
const filteredData = folderData.filter(item => item.kind === 'MdxPage' && item.route.includes(`${route}/`))
|
|
26
27
|
|
|
27
28
|
return (
|
|
@@ -30,14 +31,12 @@ export function IndexCards({route, folderData}: IndexCardsProps) {
|
|
|
30
31
|
if (item.kind !== 'MdxPage') return null
|
|
31
32
|
return (
|
|
32
33
|
<Grid.Column span={{medium: 6}} key={`cell-${item.route}`}>
|
|
33
|
-
<
|
|
34
|
-
<Card
|
|
35
|
-
|
|
36
|
-
{item.frontMatter
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
</Card>
|
|
40
|
-
</Link>
|
|
34
|
+
<Card href={`${basePath}${item.route}`} hasBorder style={{width: '100%'}}>
|
|
35
|
+
{item.frontMatter && <Card.Heading>{item.frontMatter.title}</Card.Heading>}
|
|
36
|
+
{item.frontMatter && item.frontMatter.description && (
|
|
37
|
+
<Card.Description>{item.frontMatter.description}</Card.Description>
|
|
38
|
+
)}
|
|
39
|
+
</Card>
|
|
41
40
|
</Grid.Column>
|
|
42
41
|
)
|
|
43
42
|
})}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import NextLink from 'next/link'
|
|
3
2
|
import {Box, IconButton, Link, ThemeProvider} from '@primer/react'
|
|
4
3
|
import {XIcon} from '@primer/octicons-react'
|
|
5
4
|
|
|
@@ -35,7 +34,7 @@ export function NavDrawer({isOpen, onDismiss, navItems}: NavDrawerProps) {
|
|
|
35
34
|
}}
|
|
36
35
|
>
|
|
37
36
|
<Box sx={{py: 20, pl: 4, pr: 3, alignItems: 'center', justifyContent: 'space-between', display: 'flex'}}>
|
|
38
|
-
<Link
|
|
37
|
+
<Link href="https://primer.style" sx={{fontWeight: 'bold', color: 'inherit'}}>
|
|
39
38
|
Explore
|
|
40
39
|
</Link>
|
|
41
40
|
<IconButton icon={XIcon} aria-label="Close" onClick={onDismiss} variant="invisible" />
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, {useMemo} from 'react'
|
|
2
|
-
import NextLink from 'next/link'
|
|
3
2
|
import Head from 'next/head'
|
|
4
3
|
import type {Folder, MdxFile, NextraThemeLayoutProps} from 'nextra'
|
|
5
4
|
import {useFSRoute} from 'nextra/hooks'
|
|
@@ -37,7 +36,7 @@ const {publicRuntimeConfig} = getConfig()
|
|
|
37
36
|
|
|
38
37
|
export function Theme({children, pageOpts}: NextraThemeLayoutProps) {
|
|
39
38
|
const {title, frontMatter, headings, filePath, pageMap, route} = pageOpts
|
|
40
|
-
const {locale = 'en-US', defaultLocale} = useRouter()
|
|
39
|
+
const {locale = 'en-US', defaultLocale, basePath} = useRouter()
|
|
41
40
|
const fsPath = useFSRoute()
|
|
42
41
|
const {colorMode} = useColorMode()
|
|
43
42
|
const {activePath, topLevelNavbarItems, docsDirectories, flatDocsDirectories} = useMemo(
|
|
@@ -97,8 +96,7 @@ export function Theme({children, pageOpts}: NextraThemeLayoutProps) {
|
|
|
97
96
|
<Breadcrumbs>
|
|
98
97
|
{siteTitle && (
|
|
99
98
|
<Breadcrumbs.Item
|
|
100
|
-
|
|
101
|
-
href="/"
|
|
99
|
+
href={basePath || '/'}
|
|
102
100
|
sx={{
|
|
103
101
|
color: 'var(--brand-InlineLink-color-rest)',
|
|
104
102
|
}}
|
|
@@ -109,9 +107,8 @@ export function Theme({children, pageOpts}: NextraThemeLayoutProps) {
|
|
|
109
107
|
{activePath.map((item, index) => {
|
|
110
108
|
return (
|
|
111
109
|
<Breadcrumbs.Item
|
|
112
|
-
as={NextLink}
|
|
113
110
|
key={item.name}
|
|
114
|
-
href={item.route}
|
|
111
|
+
href={`${basePath}${item.route}`}
|
|
115
112
|
selected={index === activePath.length - 1}
|
|
116
113
|
sx={{
|
|
117
114
|
textTransform: 'capitalize',
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, {useMemo} from 'react'
|
|
2
|
-
import NextLink from 'next/link'
|
|
3
2
|
import {NavList} from '@primer/react'
|
|
4
3
|
import {Folder, MdxFile, PageMapItem} from 'nextra'
|
|
5
4
|
import {useRouter} from 'next/router'
|
|
@@ -61,6 +60,7 @@ function getOcticonForType(type?: string): Icon | undefined {
|
|
|
61
60
|
|
|
62
61
|
export function Sidebar({pageMap}: SidebarProps) {
|
|
63
62
|
const router = useRouter()
|
|
63
|
+
const basePath = router.basePath
|
|
64
64
|
|
|
65
65
|
const {sidebarLinks}: ThemeConfig = publicRuntimeConfig
|
|
66
66
|
|
|
@@ -94,7 +94,7 @@ export function Sidebar({pageMap}: SidebarProps) {
|
|
|
94
94
|
|
|
95
95
|
if (item.kind === 'MdxPage') {
|
|
96
96
|
return (
|
|
97
|
-
<NavList.Item
|
|
97
|
+
<NavList.Item key={item.name} href={`${basePath}${item.route}`} sx={{textTransform: 'capitalize'}}>
|
|
98
98
|
{item.frontMatter?.title ?? item.name}
|
|
99
99
|
</NavList.Item>
|
|
100
100
|
)
|
|
@@ -109,7 +109,7 @@ export function Sidebar({pageMap}: SidebarProps) {
|
|
|
109
109
|
const shouldShowTabs = indexPage.frontMatter?.['show-tabs'] ?? false
|
|
110
110
|
if (shouldShowTabs) {
|
|
111
111
|
return (
|
|
112
|
-
<NavList.Item
|
|
112
|
+
<NavList.Item key={indexPage.name} href={`${basePath}${indexPage.route}`}>
|
|
113
113
|
{(indexPage as MdxFile).frontMatter?.title || item.name}
|
|
114
114
|
</NavList.Item>
|
|
115
115
|
)
|
|
@@ -129,9 +129,8 @@ export function Sidebar({pageMap}: SidebarProps) {
|
|
|
129
129
|
if (child.kind === 'MdxPage') {
|
|
130
130
|
return (
|
|
131
131
|
<NavList.Item
|
|
132
|
-
as={NextLink}
|
|
133
132
|
key={child.name}
|
|
134
|
-
href={child.route}
|
|
133
|
+
href={`${basePath}${child.route}`}
|
|
135
134
|
aria-current={child.route === router.pathname ? 'page' : undefined}
|
|
136
135
|
>
|
|
137
136
|
{(child as MdxFile).frontMatter?.title || item.name}
|
|
@@ -145,9 +144,8 @@ export function Sidebar({pageMap}: SidebarProps) {
|
|
|
145
144
|
)
|
|
146
145
|
return (
|
|
147
146
|
<NavList.Item
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
href={(landingPageItem as MdxFile).route}
|
|
147
|
+
key={`${(landingPageItem as MdxFile).route}`}
|
|
148
|
+
href={`${basePath}${(landingPageItem as MdxFile).route}`}
|
|
151
149
|
sx={{textTransform: 'capitalize'}}
|
|
152
150
|
aria-current={(landingPageItem as MdxFile).route === router.pathname ? 'page' : undefined}
|
|
153
151
|
>
|
|
@@ -172,12 +170,7 @@ export function Sidebar({pageMap}: SidebarProps) {
|
|
|
172
170
|
const LeadingIcon = getOcticonForType(leadingIcon)
|
|
173
171
|
|
|
174
172
|
return (
|
|
175
|
-
<NavList.Item
|
|
176
|
-
as={NextLink}
|
|
177
|
-
key={link.title}
|
|
178
|
-
href={link.href}
|
|
179
|
-
target={isExternalUrl ? '_blank' : undefined}
|
|
180
|
-
>
|
|
173
|
+
<NavList.Item key={link.title} href={link.href} target={isExternalUrl ? '_blank' : undefined}>
|
|
181
174
|
<NavList.LeadingVisual>{LeadingIcon && <LeadingIcon />}</NavList.LeadingVisual>
|
|
182
175
|
{link.title}
|
|
183
176
|
{isExternalUrl && (
|