fix(content-docs): restore behavior when pagination front matter is null (#6124)

* fix(content-docs): restore behavior when pagination front matter is null

* update snaps
This commit is contained in:
Joshua Chen 2021-12-18 10:31:31 +08:00 committed by GitHub
parent 8f18cbbeb3
commit a5d2815154
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 24 deletions

View file

@ -2,6 +2,8 @@
id: bar id: bar
title: Bar title: Bar
description: This is custom description description: This is custom description
pagination_next: null
pagination_prev: null
--- ---
# Remarkable # Remarkable

View file

@ -3,14 +3,8 @@
exports[`simple site custom pagination 1`] = ` exports[`simple site custom pagination 1`] = `
Array [ Array [
Array [ Array [
Object { undefined,
"permalink": "/docs/rootTryToEscapeSlug", undefined,
"title": "rootTryToEscapeSlug",
},
Object {
"permalink": "/docs/foo/bazSlug.html",
"title": "baz pagination_label",
},
], ],
Array [ Array [
Object { Object {

View file

@ -127,15 +127,14 @@ Object {
"frontMatter": Object { "frontMatter": Object {
"description": "This is custom description", "description": "This is custom description",
"id": "bar", "id": "bar",
"pagination_next": null,
"pagination_prev": null,
"title": "Bar", "title": "Bar",
}, },
"id": "foo/bar", "id": "foo/bar",
"lastUpdatedAt": undefined, "lastUpdatedAt": undefined,
"lastUpdatedBy": undefined, "lastUpdatedBy": undefined,
"next": Object { "next": undefined,
"permalink": "/docs/foo/bazSlug.html",
"title": "baz pagination_label",
},
"permalink": "/docs/foo/bar", "permalink": "/docs/foo/bar",
"previous": undefined, "previous": undefined,
"sidebar": "docs", "sidebar": "docs",
@ -341,13 +340,11 @@ Object {
\\"frontMatter\\": { \\"frontMatter\\": {
\\"id\\": \\"bar\\", \\"id\\": \\"bar\\",
\\"title\\": \\"Bar\\", \\"title\\": \\"Bar\\",
\\"description\\": \\"This is custom description\\" \\"description\\": \\"This is custom description\\",
\\"pagination_next\\": null,
\\"pagination_prev\\": null
}, },
\\"sidebar\\": \\"docs\\", \\"sidebar\\": \\"docs\\"
\\"next\\": {
\\"title\\": \\"baz pagination_label\\",
\\"permalink\\": \\"/docs/foo/bazSlug.html\\"
}
}", }",
"site-docs-foo-baz-md-a69.json": "{ "site-docs-foo-baz-md-a69.json": "{
\\"unversionedId\\": \\"foo/baz\\", \\"unversionedId\\": \\"foo/baz\\",

View file

@ -227,6 +227,8 @@ describe('simple site', () => {
description: 'This is custom description', description: 'This is custom description',
id: 'bar', id: 'bar',
title: 'Bar', title: 'Bar',
pagination_next: null,
pagination_prev: null,
}, },
tags: [], tags: [],
}); });

View file

@ -319,12 +319,14 @@ export function addDocNavigation(
return toDocNavigationLink(navDoc); return toDocNavigationLink(navDoc);
}; };
const previous: DocNavLink | undefined = doc.frontMatter.pagination_prev const previous =
? toNavigationLinkByDocId(doc.frontMatter.pagination_prev, 'prev') doc.frontMatter.pagination_prev !== undefined
: toNavigationLink(navigation.previous, docsById); ? toNavigationLinkByDocId(doc.frontMatter.pagination_prev, 'prev')
const next: DocNavLink | undefined = doc.frontMatter.pagination_next : toNavigationLink(navigation.previous, docsById);
? toNavigationLinkByDocId(doc.frontMatter.pagination_next, 'next') const next =
: toNavigationLink(navigation.next, docsById); doc.frontMatter.pagination_next !== undefined
? toNavigationLinkByDocId(doc.frontMatter.pagination_next, 'next')
: toNavigationLink(navigation.next, docsById);
return {...doc, sidebar: navigation.sidebarName, previous, next}; return {...doc, sidebar: navigation.sidebarName, previous, next};
} }