docs(nxdev): make sure category/index returns null if nothing is found (#12085)
This commit is contained in:
parent
9312dff014
commit
515b33eb2a
@ -50,7 +50,7 @@ export class DocumentsApi {
|
||||
* Generate the content of a "Category" or "Index" page, listing all its direct items.
|
||||
* @param path
|
||||
*/
|
||||
getDocumentIndex(path: string[]): DocumentData {
|
||||
getDocumentIndex(path: string[]): DocumentData | null {
|
||||
let items = this.documents?.itemList;
|
||||
let found: DocumentMetadata | null = null;
|
||||
let itemPathToValidate: string[] = [];
|
||||
@ -62,11 +62,14 @@ export class DocumentsApi {
|
||||
items = found.itemList;
|
||||
}
|
||||
}
|
||||
|
||||
// If the ids have found the item, check that the segment correspond to the id tree
|
||||
if (found && path.join('/') !== itemPathToValidate.join('/')) {
|
||||
found = null;
|
||||
}
|
||||
|
||||
if (!found) return null;
|
||||
|
||||
const cardListItems = items?.map((i) => ({
|
||||
name: i.name,
|
||||
path: i.path ?? '/' + path.concat(i.id).join('/'),
|
||||
|
||||
@ -215,7 +215,7 @@ export const getStaticProps: GetStaticProps = async ({
|
||||
};
|
||||
}
|
||||
|
||||
let document: DocumentData | undefined;
|
||||
let document: DocumentData | null = null;
|
||||
try {
|
||||
document = documentsApi.getDocument(params.segments);
|
||||
} catch (e) {
|
||||
@ -226,6 +226,7 @@ export const getStaticProps: GetStaticProps = async ({
|
||||
} catch (e) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
if (document) {
|
||||
return {
|
||||
props: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user