Skip to content

Commit

Permalink
fix (offset - 1) pagination (#584)
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
Dimitri POSTOLOV authored Jan 16, 2024
1 parent 007ccbd commit 08de422
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 28 deletions.
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': '',
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.

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
}

0 comments on commit 08de422

Please sign in to comment.