mirror of
https://github.com/versia-pub/docs.git
synced 2025-12-06 06:18:19 +01:00
feat: 📝 Add Like extension
This commit is contained in:
parent
07f8de757b
commit
fba00bb82c
109
app/extensions/likes/page.mdx
Normal file
109
app/extensions/likes/page.mdx
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
export const metadata = {
|
||||
title: 'Likes Extension',
|
||||
description:
|
||||
'The Likes extension adds support for users to like and dislike notes.',
|
||||
}
|
||||
|
||||
# Likes Extension
|
||||
|
||||
The Likes extension adds support for users to like and dislike notes. {{ className: 'lead' }}
|
||||
|
||||
Implementations should make sure that users cannot like and dislike the same note at the same time. If a user dislikes a note they have already liked, the like should be removed, and vice versa.
|
||||
|
||||
## Likes
|
||||
|
||||
Likes are a way for users to show appreciation for a note, like Twitter's "heart" button or Reddit's "upvote".
|
||||
|
||||
### Entity Definition
|
||||
|
||||
<Row>
|
||||
<Col>
|
||||
<Properties>
|
||||
<Property name="extension_type" type="string" required={true}>
|
||||
Must be `org.lysand:likes/Like`.
|
||||
</Property>
|
||||
<Property name="author" type="URI" required={true} typeLink="/types#uri">
|
||||
Creator of the Like.
|
||||
</Property>
|
||||
<Property name="liked" type="URI" required={true} typeLink="/types#uri">
|
||||
URI of the note being liked. Must link to a [Note](/entities/notes).
|
||||
</Property>
|
||||
</Properties>
|
||||
</Col>
|
||||
|
||||
<Col sticky>
|
||||
|
||||
```jsonc {{ 'title': 'Example Like' }}
|
||||
{
|
||||
"id": "3e7e4750-afd4-4d99-a256-02f0710a0520",
|
||||
"type": "Extension",
|
||||
"extension_type": "org.lysand:likes/Like",
|
||||
"created_at": "2021-01-01T00:00:00.000Z",
|
||||
"author": "https://example.com/users/6e0204a2-746c-4972-8602-c4f37fc63bbe",
|
||||
"uri": "https://example.com/likes/3e7e4750-afd4-4d99-a256-02f0710a0520",
|
||||
"liked": "https://otherexample.org/notes/fmKZ763jzIU8"
|
||||
}
|
||||
```
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
## Dislikes
|
||||
|
||||
Dislikes are a way for users to show disapproval for a note, like YouTube's "dislikes" or Reddit's "downvotes".
|
||||
|
||||
### Entity Definition
|
||||
|
||||
<Row>
|
||||
<Col>
|
||||
<Properties>
|
||||
<Property name="extension_type" type="string" required={true}>
|
||||
Must be `org.lysand:likes/Dislike`.
|
||||
</Property>
|
||||
<Property name="author" type="URI" required={true} typeLink="/types#uri">
|
||||
Creator of the Dislike.
|
||||
</Property>
|
||||
<Property name="disliked" type="URI" required={true} typeLink="/types#uri">
|
||||
URI of the note being disliked. Must link to a [Note](/entities/notes).
|
||||
</Property>
|
||||
</Properties>
|
||||
</Col>
|
||||
|
||||
<Col sticky>
|
||||
|
||||
```jsonc {{ 'title': 'Example Dislike' }}
|
||||
{
|
||||
"id": "3e7e4750-afd4-4d99-a256-02f0710a0520",
|
||||
"type": "Extension",
|
||||
"extension_type": "org.lysand:likes/Dislike",
|
||||
"created_at": "2021-01-01T00:00:00.000Z",
|
||||
"author": "https://example.com/users/6e0204a2-746c-4972-8602-c4f37fc63bbe",
|
||||
"uri": "https://example.com/dislikes/3e7e4750-afd4-4d99-a256-02f0710a0520",
|
||||
"disliked": "https://otherexample.org/notes/fmKZ763jzIU8"
|
||||
}
|
||||
```
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
## Undoing Likes and Dislikes
|
||||
|
||||
To undo a like or dislike, an [Undo](/entities/undo) entity should be used. The `object` property of the Undo entity should link to the Like or Dislike entity to be removed.
|
||||
|
||||
## User Collections
|
||||
|
||||
The Likes extension adds the following collections to the [User](/entities/users) entity:
|
||||
|
||||
- `likes`: A [Collection](/structures/collection) of all the notes the user has liked.
|
||||
- `dislikes`: A [Collection](/structures/collection) of all the notes the user has disliked.
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"type": "User",
|
||||
...
|
||||
"collections": {
|
||||
...
|
||||
"org.lysand:likes/Likes": "https://example.com/users/6e0204a2-746c-4972-8602-c4f37fc63bbe/likes",
|
||||
"org.lysand:likes/Dislikes": "https://example.com/users/6e0204a2-746c-4972-8602-c4f37fc63bbe/dislikes"
|
||||
}
|
||||
}
|
||||
|
|
@ -278,7 +278,10 @@ export const navigation: NavGroup[] = [
|
|||
},
|
||||
{
|
||||
title: "Extensions",
|
||||
links: [{ title: "WebSockets", href: "/extensions/websockets" }],
|
||||
links: [
|
||||
{ title: "Likes", href: "/extensions/likes" },
|
||||
{ title: "WebSockets", href: "/extensions/websockets" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue