-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(examples): misc improvements to the draft preview example (#10876)
There were a number of things wrong or could have been improved with the [Draft Preview Example](https://github.com/payloadcms/payload/tree/main/examples/draft-preview), namely: - The package.json was missing `"type": "modue"` which would throw ESM related import errors on startup - The preview secret was missing entirely, with pointless logic was written to throw an error if it missing in the search params as opposed to not matching the environment secret - The `/next/exit-preview` route was duplicated twice - The preview endpoint was unnecessarily querying the database for a matching document as opposed to letting the underlying page itself 404 as needed, and it was also throwing an inaccurate error message Some less critical changes were: - The page query was missing the `depth` and `limit` parameters which is best practice to optimize performance - The logic to format search params in the preview URL was unnecessarily complex - Utilities like `generatePreviewPath` and `getGlobals` were unnecessarily obfuscating simple functions - The `/preview` and `/exit-preview` routes were unecessarily nested within a `/next` page segment - Payload types weren't aliased
- Loading branch information
1 parent
8f27f85
commit 2b9ee62
Showing
22 changed files
with
1,275 additions
and
1,330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.