Skip to content

Commit

Permalink
docs: explain usage with v4 and fix component props
Browse files Browse the repository at this point in the history
fix #14
fix #13
  • Loading branch information
Barbapapazes committed Aug 27, 2024
1 parent 31f1dd4 commit ffc1c4e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ Easy!

### Define Abilities

> [!NOTE]
> With the upcoming Nuxt4, you can store your abilities in the `app/utils/abilities.ts` file. Then, you can import them in your server folder using `~/utils/abilities`.
> See an example with [the project Orion](https://github.com/Barbapapazes/orion/blob/main/app/utils/users/abilities.ts).
> [!NOTE]
> With Nuxt4, a new `shared` directory will be introduced to easily share code between the client and the server.
> See [the issue](https://github.com/nuxt/nuxt/issues/28675).
Now the resolvers are set up, you can define your first ability. An ability is a function that takes at least the user, and returns a boolean to indicate if the user can perform the action. It can also take additional arguments.

I recommend to create a new file `utils/abilities.ts` to create your abilities:
Expand Down Expand Up @@ -212,8 +220,8 @@ The module provides 2 components help you to conditionally show part of the UI.
```vue
<template>
<Can
:ability="editPost"
:args="[post]"
:bouncer-ability="editPost"
:args="[post]" // Optional if the ability does not take any arguments
>
<button>Edit</button>
</Can>
Expand All @@ -227,8 +235,8 @@ As a counterpart, you can use the `Cannot` component to render the button only i
```vue
<template>
<Cannot
:ability="editPost"
:args="[post]"
:bouncer-ability="editPost"
:args="[post]" // Optional if the ability does not take any arguments
>
<p>You're not allowed to edit the post.</p>
</Cannot>
Expand Down

0 comments on commit ffc1c4e

Please sign in to comment.