Add resource generator plugin
- Dominant language
- TypeScript
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
## Command
unthink generate resource my-resource-name
## Arguments
1. Kebab-cased name for the resource. E.g., "hello-world"
## Default Result
By default, the following file(s) will be created from template:
- `src/server/resources/-resource.ts`
- Resource `name` will be set to the match the resource name. E.g., "hello-world" would be `name: "Hello World"`.
- `basePath` will be set to `/`, E.g., `/hello-world`.
- `routes` will contain the following:
- a `view` handler serving up the template
- a `data` handler serving up a JSON endpoint that returns an empty object
- `src/content/templates/.njk`. E.g., "hello-world" would create a template called "hello-world.njk".
By default, the following file(s) will be modified:
- `src/server/resource-definitions.ts` will be modified to include:
- The `import` to the new resource
- The new resource will be added to the `export default` list
## Options
### --view
Use `--view` to provide an alternate name for the nunjucks template
### --no-view
Use `--no-view` to skip generation of a template file and the inclusion of the `view(...)` example in the routes.
### --no-data
Use `--no-data` to skip the inclusion of the JSON `data(...)` endpoint in the routes.
### --base-path
Use `--base-path` to set the `basePath` of the resource.
unthink generate resource hello-world --base-path="/"
### --entry
Use `--entry` to have the nunjucks template include a reference to an entry bundle.
unthink g resource hello-world --entry=hello-world
Would add something like this to the template:
```
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.