Skip to content

Commit

Permalink
add changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
rezrah committed Jan 24, 2025
1 parent 4ec8bc9 commit bfe68b1
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/olive-donuts-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/doctocat-nextjs': minor
---

Upgrade to Nextra@v3
30 changes: 25 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions packages/site/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"eslint.options": {
"configFile": "eslint.config.cjs"
}
}
7 changes: 7 additions & 0 deletions packages/site/eslint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ module.exports = {
tsconfigRootDir: __dirname,
},
rules: {
'import/extensions': [
'error',
'ignorePackages',
{
js: 'always',
},
],
'@next/next/no-img-element': 'off',
'primer-react/no-system-props': 'off',
},
Expand Down
5 changes: 5 additions & 0 deletions packages/theme/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"eslint.options": {
"configFile": "eslint.config.cjs"
}
}
7 changes: 1 addition & 6 deletions packages/theme/components/layout/root-layout/Theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,7 @@ export function Theme({children, pageOpts}: NextraThemeLayoutProps) {
const isHomePage = route === '/'
const isIndexPage = /index\.mdx?$/.test(filePath) && !isHomePage && !frontMatter['show-tabs']
const data = !isHomePage && activePath[activePath.length - 2]
const filteredTabData: MdxFile[] =
data && hasChildren(data)
? ((data as Folder).children.filter(child => {
return child
}) as MdxFile[])
: []
const filteredTabData: MdxFile[] = data && hasChildren(data) ? ((data as Folder).children as MdxFile[]) : []

/**
* Uses a frontmatter 'keywords' value (as an array)
Expand Down
14 changes: 7 additions & 7 deletions packages/theme/components/layout/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {useMemo} from 'react'
import NextLink from 'next/link'
import {NavList} from '@primer/react'
import {Folder, MdxFile, PageMapItem} from 'nextra'
import {Folder, MdxFile} from 'nextra'
import {useRouter} from 'next/router'
import getConfig from 'next/config'

Expand All @@ -16,6 +16,10 @@ type SidebarProps = {

const {publicRuntimeConfig} = getConfig()

const hasShowTabs = (child: DocsItem): boolean => {
return child.name === 'index' && (child as MdxFile).frontMatter?.['show-tabs'] === true
}

export function Sidebar({pageMap}: SidebarProps) {
const router = useRouter()

Expand Down Expand Up @@ -75,12 +79,8 @@ export function Sidebar({pageMap}: SidebarProps) {
{item.children &&
item.children
.sort((a, b) => (a.name === 'index' ? -1 : b.name === 'index' ? 1 : 0)) // puts index page first
.filter(child => {
return (
child.name !== 'index' ||
((child.name === 'index' && (child as MdxFile).frontMatter?.['show-tabs']) ?? false)
)
}) // only show index page if it has show-tabs
// only show index page if it has show-tabs
.filter(child => child.name !== 'index' || hasShowTabs(child))
.map((child: DocsItem) => {
if (child.type === 'doc') {
return (
Expand Down

0 comments on commit bfe68b1

Please sign in to comment.