Parent pages are now Endpoint sources
This commit is contained in:
		
							parent
							
								
									9f1caef009
								
							
						
					
					
						commit
						7d1f796282
					
				
							
								
								
									
										15
									
								
								src/sdk.ts
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/sdk.ts
									
									
									
									
									
								
							| @ -156,7 +156,7 @@ export type EndpointFolder = EndpointFolderPreview & { | |||||||
|         value: EndpointPagePreview; |         value: EndpointPagePreview; | ||||||
|       } |       } | ||||||
|   )[]; |   )[]; | ||||||
|   parentPages: ParentPage[]; |   parentPages: EndpointSource[]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export type EndpointHomeFolder = EndpointFolderPreview & { | export type EndpointHomeFolder = EndpointFolderPreview & { | ||||||
| @ -226,13 +226,7 @@ export type EndpointPage = EndpointPagePreview & { | |||||||
|     proofreaders: EndpointRecorder[]; |     proofreaders: EndpointRecorder[]; | ||||||
|     toc: TableOfContentEntry[]; |     toc: TableOfContentEntry[]; | ||||||
|   })[]; |   })[]; | ||||||
|   parentPages: ParentPage[]; |   parentPages: EndpointSource[]; | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| export type ParentPage = { |  | ||||||
|   slug: string; |  | ||||||
|   collection: Collections; |  | ||||||
|   translations: { language: string; name: string }[]; |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export type EndpointCollectiblePreview = { | export type EndpointCollectiblePreview = { | ||||||
| @ -307,7 +301,7 @@ export type EndpointCollectible = EndpointCollectiblePreview & { | |||||||
|           }[]; |           }[]; | ||||||
|         }; |         }; | ||||||
|   }[]; |   }[]; | ||||||
|   parentPages: ParentPage[]; |   parentPages: EndpointSource[]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export type TableOfContentEntry = { | export type TableOfContentEntry = { | ||||||
| @ -350,7 +344,8 @@ export type EndpointSource = | |||||||
|         | { type: "timestamp"; timestamp: string } |         | { type: "timestamp"; timestamp: string } | ||||||
|         | { type: "custom"; translations: { language: string; note: string }[] }; |         | { type: "custom"; translations: { language: string; note: string }[] }; | ||||||
|     } |     } | ||||||
|   | { type: "page"; page: EndpointPagePreview }; |   | { type: "page"; page: EndpointPagePreview } | ||||||
|  |   | { type: "folder"; folder: EndpointFolderPreview }; | ||||||
| 
 | 
 | ||||||
| export type PayloadImage = { | export type PayloadImage = { | ||||||
|   url: string; |   url: string; | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| import { Collections } from "../constants"; | import { convertCollectibleToPreview } from "../collections/Collectibles/endpoints/getBySlugEndpoint"; | ||||||
| import { EndpointRecorder, EndpointTag, EndpointTagsGroup, ParentPage } from "../sdk"; | import { convertFolderToPreview } from "../collections/Folders/endpoints/getBySlugEndpoint"; | ||||||
|  | import { EndpointRecorder, EndpointSource, EndpointTag, EndpointTagsGroup } from "../sdk"; | ||||||
| import { Collectible, Folder, Recorder, Tag } from "../types/collections"; | import { Collectible, Folder, Recorder, Tag } from "../types/collections"; | ||||||
| import { isPayloadArrayType, isPayloadType, isPublished, isValidPayloadImage } from "./asserts"; | import { isPayloadArrayType, isPayloadType, isPublished, isValidPayloadImage } from "./asserts"; | ||||||
| 
 | 
 | ||||||
| @ -49,32 +50,23 @@ export const handleParentPages = ({ | |||||||
| }: { | }: { | ||||||
|   collectibles?: (string | Collectible)[] | null | undefined; |   collectibles?: (string | Collectible)[] | null | undefined; | ||||||
|   folders?: (string | Folder)[] | null | undefined; |   folders?: (string | Folder)[] | null | undefined; | ||||||
| }): ParentPage[] => { | }): EndpointSource[] => { | ||||||
|   const result: ParentPage[] = []; |   const result: EndpointSource[] = []; | ||||||
| 
 | 
 | ||||||
|   if (collectibles && isPayloadArrayType(collectibles)) { |   if (collectibles && isPayloadArrayType(collectibles)) { | ||||||
|     collectibles.filter(isPublished).forEach(({ slug, translations }) => { |     collectibles.filter(isPublished).forEach((collectible) => { | ||||||
|       result.push({ |       result.push({ | ||||||
|         collection: Collections.Collectibles, |         type: "collectible", | ||||||
|         slug, |         collectible: convertCollectibleToPreview(collectible), | ||||||
|         translations: translations.map(({ language, title }) => ({ |  | ||||||
|           language: isPayloadType(language) ? language.id : language, |  | ||||||
|           name: title, // TODO: Use the entire pretitle + title + subtitle
 |  | ||||||
|         })), |  | ||||||
|       }); |       }); | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   if (folders && isPayloadArrayType(folders)) { |   if (folders && isPayloadArrayType(folders)) { | ||||||
|     folders.forEach(({ slug, translations }) => { |     folders.forEach((folder) => { | ||||||
|       result.push({ |       result.push({ | ||||||
|         collection: Collections.Folders, |         type: "folder", | ||||||
|         slug, |         folder: convertFolderToPreview(folder), | ||||||
|         translations: |  | ||||||
|           translations?.map(({ language, name }) => ({ |  | ||||||
|             language: isPayloadType(language) ? language.id : language, |  | ||||||
|             name, |  | ||||||
|           })) ?? [], |  | ||||||
|       }); |       }); | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 DrMint
						DrMint