Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (offset - 1) pagination #584

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 6 additions & 21 deletions packages/nextra-theme/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,30 +96,15 @@ export default function NextraLayout({ children, pageOpts, pageProps }: NextraTh
const result = normalizePages({
list: pageMap,
locale,
defaultLocale: defaultLocale,
defaultLocale,
route: fsPath,
})

function removeNonExistedRoutes(items: Item[]): Item[] {
return items.reduce<Item[]>((acc, curr) => {
if (curr.route || curr.type === 'heading' || curr.type === 'separator') {
if (curr.children) {
curr.children = removeNonExistedRoutes(curr.children)
}
acc.push(curr)
}
return acc
}, [])
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-return -- i don't know why it's complain
return {
...result,
directories: removeNonExistedRoutes(result.directories),
flatDirectories: result.flatDirectories.filter(
(item) => item.type !== 'separator' && item.type !== 'heading' && item.route !== '',
),
for (const item of result.flatDocsDirectories) {
if (!item.route) {
throw new Error(`Route "${item.name}" is not exist. Remove this field from _meta.js file`)
}
}
return result
}, [defaultLocale, fsPath, locale, pageMap])

// Provide `markOutlineItem` to the `DocumentContext` so child `Heading` components can mark outline items as "in or above view" or not
Expand Down
6 changes: 3 additions & 3 deletions packages/nextra-theme/src/layout/MDXLayoutPagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { buildTransition, Divider, Flex, Icon, Link, Spacing, Text, useI18n } fr
import { NavContext } from '@/layout'

export const MDXLayoutPagination = () => {
const { flatDirectories, activeIndex } = useContext(NavContext)!
const { flatDocsDirectories, activeIndex } = useContext(NavContext)!
const { t } = useI18n<any>()

const prev = flatDirectories[activeIndex - 1]
const next = flatDirectories[activeIndex + 1]
const prev = flatDocsDirectories[activeIndex - 1]
const next = flatDocsDirectories[activeIndex + 1]

if (!prev && !next) return null

Expand Down
1 change: 1 addition & 0 deletions website/pages/ar/querying/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import meta from '../../en/querying/_meta.js'

export default {
...meta,
'graph-client': undefined, // Remove from sidebar, defined only for `en` language
}
1 change: 0 additions & 1 deletion website/pages/en/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default {
network: 'The Graph Network',
sunrise: 'Sunrise FAQ',
billing: '',
'network-transition-faq': '',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this hidden route produced offset - 1 issue since, I used flatDirectories list instead of flatDocsDirectories

because in original nextra-theme-docs were props naming confusing

https://github.com/shuding/nextra/blob/2f001d897f2109b24600f66fe2009e5f788b980c/packages/nextra-theme-docs/src/components/nav-links.tsx#L22
https://github.com/shuding/nextra/blob/2f001d897f2109b24600f66fe2009e5f788b980c/packages/nextra-theme-docs/src/index.tsx#L220

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice catch!

glossary: '',
tokenomics: 'Tokenomics',
arbitrum: 'Scaling with Arbitrum',
Expand Down
6 changes: 3 additions & 3 deletions website/pages/en/quick-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ See the following screenshot for an example for what to expect when initializing

The previous commands create a scaffold subgraph that you can use as a starting point for building your subgraph. When making changes to the subgraph, you will mainly work with three files:

- Manifest (subgraph.yaml) - The manifest defines what datasources your subgraphs will index.
- Schema (schema.graphql) - The GraphQL schema defines what data you wish to retrieve from the subgraph.
- AssemblyScript Mappings (mapping.ts) - This is the code that translates data from your datasources to the entities defined in the schema.
- Manifest (`subgraph.yaml`) - The manifest defines what datasources your subgraphs will index.
- Schema (`schema.graphql`) - The GraphQL schema defines what data you wish to retrieve from the subgraph.
- AssemblyScript Mappings (`mapping.ts`) - This is the code that translates data from your datasources to the entities defined in the schema.
Comment on lines +70 to +72
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just better to use inline code blocks for filenames


For more information on how to write your subgraph, see [Creating a Subgraph](/developing/creating-a-subgraph).

Expand Down
1 change: 1 addition & 0 deletions website/pages/es/querying/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import meta from '../../en/querying/_meta.js'

export default {
...meta,
'graph-client': undefined, // Remove from sidebar, defined only for `en` language
}
1 change: 1 addition & 0 deletions website/pages/hi/querying/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import meta from '../../en/querying/_meta.js'

export default {
...meta,
'graph-client': undefined, // Remove from sidebar, defined only for `en` language
}
1 change: 1 addition & 0 deletions website/pages/ja/querying/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import meta from '../../en/querying/_meta.js'

export default {
...meta,
'graph-client': undefined, // Remove from sidebar, defined only for `en` language
}
1 change: 1 addition & 0 deletions website/pages/mr/querying/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import meta from '../../en/querying/_meta.js'

export default {
...meta,
'graph-client': undefined, // Remove from sidebar, defined only for `en` language
}
1 change: 1 addition & 0 deletions website/pages/pt/querying/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import meta from '../../en/querying/_meta.js'

export default {
...meta,
'graph-client': undefined, // Remove from sidebar, defined only for `en` language
}
1 change: 1 addition & 0 deletions website/pages/ru/querying/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import meta from '../../en/querying/_meta.js'

export default {
...meta,
'graph-client': undefined, // Remove from sidebar, defined only for `en` language
}
1 change: 1 addition & 0 deletions website/pages/sv/querying/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import meta from '../../en/querying/_meta.js'

export default {
...meta,
'graph-client': undefined, // Remove from sidebar, defined only for `en` language
}
1 change: 1 addition & 0 deletions website/pages/tr/querying/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import meta from '../../en/querying/_meta.js'

export default {
...meta,
'graph-client': undefined, // Remove from sidebar, defined only for `en` language
}
1 change: 1 addition & 0 deletions website/pages/ur/querying/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import meta from '../../en/querying/_meta.js'

export default {
...meta,
'graph-client': undefined, // Remove from sidebar, defined only for `en` language
}
1 change: 1 addition & 0 deletions website/pages/zh/querying/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import meta from '../../en/querying/_meta.js'

export default {
...meta,
'graph-client': undefined, // Remove from sidebar, defined only for `en` language
}
Loading