chore: docs stubbing

This commit is contained in:
James
2023-10-06 10:20:44 -04:00
parent c2a99c8edc
commit 78d6643950
15 changed files with 152 additions and 21 deletions

View File

@@ -0,0 +1,6 @@
---
title: Bundlers
label: Bundlers
order: 60
desc: NEEDS TO BE WRITTEN
---

View File

@@ -0,0 +1,28 @@
---
title: Environment Variables in Admin UI
label: Environment Variables
order: 100
desc: NEEDS TO BE WRITTEN
---
TODO: expand on this and make sure it looks nice, talk about how if you use a `process.env.SERVER_URL`, it might not be usable in your Payload config in your admin UI, but it needs to be, so it should be prefixed like `process.env.PAYLOAD_PUBLIC_SERVER_URL` to work in both places
## Admin environment vars
<Banner type="warning">
<strong>Important:</strong>
<br />
Be careful about what variables you provide to your client-side code. Analyze every single one to
make sure that you're not accidentally leaking anything that an attacker could exploit. Only keys
that are safe to be available to everyone in plain text should be provided to your Admin panel.
</Banner>
By default, `env` variables are **not** provided to the Admin panel for security and safety reasons. But, Payload provides you with a way to still provide `env` vars to your frontend code.
**Payload will automatically supply any present `env` variables that are prefixed with `PAYLOAD_PUBLIC_` directly to the Admin panel.**
For example, if you've got the following environment variable:
`PAYLOAD_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_XXXXXXXXXXXXXXXXXX`
This key will automatically be made available to the Payload bundle and can be referenced in your Admin component code as `process.env.PAYLOAD_PUBLIC_STRIPE_PUBLISHABLE_KEY`.

View File

@@ -0,0 +1,9 @@
---
title: Excluding server-only code from admin UI
label: Excluding server code
order: 70
desc: NEEDS TO BE WRITTEN
---
- Talk about the theory behind using aliases to exclude files
- Talk about environment variables maybe?

View File

@@ -8,6 +8,7 @@ keywords: admin, components, custom, customize, documentation, Content Managemen
Payload dynamically generates a beautiful, fully functional React admin panel to manage your data. It's extremely powerful and can be customized / extended upon easily by swapping in your own React components. You can add additional views, modify how built-in views look / work, swap out Payload branding for your client's, build your own field types and much more. Payload dynamically generates a beautiful, fully functional React admin panel to manage your data. It's extremely powerful and can be customized / extended upon easily by swapping in your own React components. You can add additional views, modify how built-in views look / work, swap out Payload branding for your client's, build your own field types and much more.
TODO: change the sentence below to reference our adapter pattern, and officially supported bundlers, linking to Vite and Webpack docs pages specifically
The Payload Admin panel is built with Webpack, code-split, highly performant (even with 100+ fields), and written fully in TypeScript. The Payload Admin panel is built with Webpack, code-split, highly performant (even with 100+ fields), and written fully in TypeScript.
<Banner type="success"> <Banner type="success">
@@ -24,6 +25,8 @@ _Screenshot of the Admin panel while editing a document from an example `AllFiel
All options for the Admin panel are defined in your base Payload config file. All options for the Admin panel are defined in your base Payload config file.
TODO: add `vite` and `bundler` properties to the table below
| Option | Description | | Option | Description |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `user` | The `slug` of a Collection that you want be used to log in to the Admin dashboard. [More](/docs/admin/overview#the-admin-user-collection) | | `user` | The `slug` of a Collection that you want be used to log in to the Admin dashboard. [More](/docs/admin/overview#the-admin-user-collection) |

15
docs/admin/vite.mdx Normal file
View File

@@ -0,0 +1,15 @@
---
title: Vite
label: Vite
order: 90
desc: NEEDS TO BE WRITTEN
---
- Show how to install official bundler
- Give banner "warning" that this is in beta
- Talk about how you should see performance improvements in both build times and HMR
- Initial load might not be substantially faster, because Vite pre-bundles dependencies
- Talk about the new `admin.vite` property
- Talk about how for compatibility, the Vite config still automatically adds aliases that come in from the `admin.webpack` property
- Aliases work differently in Vite vs. Webpack (you can't pass Vite an absolute path to your alias source, it needs to match perfectly)

View File

@@ -1,11 +1,15 @@
--- ---
title: Webpack title: Webpack
label: Webpack label: Webpack
order: 60 order: 80
desc: The Payload admin panel uses Webpack 5 and supports many common functionalities such as SCSS and Typescript out of the box to give you more freedom. desc: The Payload admin panel uses Webpack 5 and supports many common functionalities such as SCSS and Typescript out of the box to give you more freedom.
keywords: admin, webpack, documentation, Content Management System, cms, headless, javascript, node, react, express keywords: admin, webpack, documentation, Content Management System, cms, headless, javascript, node, react, express
--- ---
TODO: rewrite this
- Talk about how Webpack is stable, and should be used unless you are adventurous.
- Show a code example about how to install and pass the Webpack bundler to the Payload config
Payload uses Webpack 5 to build the Admin panel. It comes with support for many common functionalities such as SCSS and Typescript out of the box, but there are many cases where you may need to add support for additional functionalities. Payload uses Webpack 5 to build the Admin panel. It comes with support for many common functionalities such as SCSS and Typescript out of the box, but there are many cases where you may need to add support for additional functionalities.
To extend the Webpack config, add the `webpack` key to your base Payload config, and provide a function that accepts the default Webpack config as its only argument: To extend the Webpack config, add the `webpack` key to your base Payload config, and provide a function that accepts the default Webpack config as its only argument:
@@ -28,6 +32,10 @@ export default buildConfig({
}) })
``` ```
TODO: move the aliasing section to its own page
- Talk about how Webpack is stable, and should be used unless you are adventurous.
- Show a code example about how to install and pass the Webpack bundler to the Payload config
### Aliasing server-only modules ### Aliasing server-only modules
A common use case for extending the Payload config is to alias server-only modules, thus preventing them from inclusion into the browser JavaScript bundle. A common use case for extending the Payload config is to alias server-only modules, thus preventing them from inclusion into the browser JavaScript bundle.
@@ -175,23 +183,3 @@ Now, when Webpack sees that you're attempting to import your `createStripeSubscr
[cached](https://webpack.js.org/configuration/cache/) in `node_modules/.cache/webpack`. Try [cached](https://webpack.js.org/configuration/cache/) in `node_modules/.cache/webpack`. Try
deleting that folder and restarting your server. deleting that folder and restarting your server.
</Banner> </Banner>
## Admin environment vars
<Banner type="warning">
<strong>Important:</strong>
<br />
Be careful about what variables you provide to your client-side code. Analyze every single one to
make sure that you're not accidentally leaking anything that an attacker could exploit. Only keys
that are safe to be available to everyone in plain text should be provided to your Admin panel.
</Banner>
By default, `env` variables are **not** provided to the Admin panel for security and safety reasons. But, Payload provides you with a way to still provide `env` vars to your frontend code.
**Payload will automatically supply any present `env` variables that are prefixed with `PAYLOAD_PUBLIC_` directly to the Admin panel.**
For example, if you've got the following environment variable:
`PAYLOAD_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_XXXXXXXXXXXXXXXXXX`
This key will automatically be made available to the Payload bundle and can be referenced in your Admin component code as `process.env.PAYLOAD_PUBLIC_STRIPE_PUBLISHABLE_KEY`.

View File

View File

View File

@@ -0,0 +1,13 @@
---
title: Implementing Live Preview in your app
label: Frontend Implementation
order: 20
desc: NEED TO WRITE
keywords: NEED TO WRITE
---
- Talk about in detail how it works on the frontend
- How you should write your frontend to be "safe" and not break if there is no data filled in a required field, etc.
- Your UI should be reactive to new props
- Loading states
- Etc.

View File

@@ -0,0 +1,13 @@
---
title: Live Preview
label: Overview
order: 10
desc: NEED TO WRITE
keywords: NEED TO WRITE
---
TODO: write docs here
- Show screenshot of the usage
- Talk about how it works at a high level
- Talk about the property on `collectionConfig.admin`
- Talk about the React hook, and the subsequent package that it relies on which can be used for other frameworks

View File

@@ -0,0 +1,10 @@
---
title: Admin panel compatibility
label: Admin compatibility
order: 20
desc: NEEDS TO BE WRITTEN
---
TODO: talk about how plugins need to ensure compatibility with both Vite and Webpack
- It's best practice to alias your plugin to an admin-only version, so if you have admin-only changes, put them in the admin plugin, and then leave the full plugin, complete with server code, to be installed on the server side

View File

@@ -0,0 +1,10 @@
---
title: Rendering Rich Text on your Frontend
label: Rendering on Frontend
order: 20
desc: NEED TO WRITE
keywords: NEED TO WRITE
---
Give an example for how to render JSX on the frontend
In the future, we will add docs that show how to add virtual fields for HTML / MDX transforming

View File

@@ -0,0 +1,11 @@
---
title: Lexical Rich Text
label: Lexical
order: 30
desc: NEED TO WRITE
keywords: NEED TO WRITE
---
Talk about the reasons why we are using Lexical, what it does well, and where we plan to go in the future
Show a code snippet for how to install it
Show how to configure it, with options

View File

@@ -0,0 +1,16 @@
---
title: Overview
label: Rich Text Field
order: 10
desc: NEED TO WRITE
keywords: NEED TO WRITE
---
TODO:
- Talk about how Payload supports two rich text editors, and they work on an "adapter" pattern, which means you need to install the one you want to use separately and pass it to config
- Talk about how Slate is still supported for legacy projects, but we are moving to Lexical from here on out which offers more features
- For new projects as of 2.0, use Lexical
- For existing projects, use Slate
- Probably move some of the more complex docs from Fields -> Rich Text over to this set of docs
- Show how you can install an editor at the top level, or override on a field-by-field basis (not recommended, no reason to have 2 editors installed. Lots of JS loaded)

9
docs/rich-text/slate.mdx Normal file
View File

@@ -0,0 +1,9 @@
---
title: Slate Rich Text
label: Slate
order: 40
desc: NEED TO WRITE
keywords: NEED TO WRITE
---
Recreate a similar approach to Lexical here