From 9db7cfccda70f4e33801817c37be3fd59c004f71 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Tue, 24 Dec 2024 14:01:09 +0100 Subject: [PATCH] feat: :sparkles: Add unique ID to every property on docs --- app/entities/delete/page.mdx | 2 +- app/entities/follow-accept/page.mdx | 2 +- app/entities/follow-reject/page.mdx | 2 +- app/entities/follow/page.mdx | 2 +- app/entities/instance-metadata/page.mdx | 2 +- app/entities/note/page.mdx | 2 +- app/entities/page.mdx | 2 +- app/entities/unfollow/page.mdx | 2 +- app/entities/user/page.mdx | 2 +- app/extensions/custom-emojis/page.mdx | 4 +- app/extensions/groups/page.mdx | 12 +-- app/extensions/instance-messaging/page.mdx | 2 +- app/extensions/interaction-controls/page.mdx | 2 +- app/extensions/likes/page.mdx | 4 +- app/extensions/migration/page.mdx | 4 +- app/extensions/page.mdx | 4 +- app/extensions/polls/page.mdx | 4 +- app/extensions/reactions/page.mdx | 2 +- app/extensions/reports/page.mdx | 2 +- app/extensions/share/page.mdx | 2 +- app/extensions/vanity/page.mdx | 2 +- app/extensions/websockets/page.mdx | 2 +- app/federation/http/page.mdx | 4 +- app/links/page.mdx | 2 +- app/structures/collection/page.mdx | 4 +- app/structures/content-format/page.mdx | 2 +- components/Property.tsx | 105 +++++++++++++++++++ components/mdx.tsx | 79 +------------- 28 files changed, 144 insertions(+), 116 deletions(-) create mode 100644 components/Property.tsx diff --git a/app/entities/delete/page.mdx b/app/entities/delete/page.mdx index edb75a1..ba9b3f6 100644 --- a/app/entities/delete/page.mdx +++ b/app/entities/delete/page.mdx @@ -19,7 +19,7 @@ Having the authorization is defined as: - + This is a [**Transient Entity**](/entities#transient-entities) and does not have a URI. diff --git a/app/entities/follow-accept/page.mdx b/app/entities/follow-accept/page.mdx index 620bb96..103b4b0 100644 --- a/app/entities/follow-accept/page.mdx +++ b/app/entities/follow-accept/page.mdx @@ -13,7 +13,7 @@ export const metadata = { - + This is a [**Transient Entity**](/entities#transient-entities) and does not have a URI. diff --git a/app/entities/follow-reject/page.mdx b/app/entities/follow-reject/page.mdx index c87435c..7492789 100644 --- a/app/entities/follow-reject/page.mdx +++ b/app/entities/follow-reject/page.mdx @@ -23,7 +23,7 @@ But it can also be used when Bob is already following Alice, in the case that: - + This is a [**Transient Entity**](/entities#transient-entities) and does not have a URI. diff --git a/app/entities/follow/page.mdx b/app/entities/follow/page.mdx index e72d25e..7287542 100644 --- a/app/entities/follow/page.mdx +++ b/app/entities/follow/page.mdx @@ -55,7 +55,7 @@ Once a follow relationship is established, the **followee**'s instance should se - + This is a [**Transient Entity**](/entities#transient-entities) and does not have a URI. diff --git a/app/entities/instance-metadata/page.mdx b/app/entities/instance-metadata/page.mdx index ca8c233..4232622 100644 --- a/app/entities/instance-metadata/page.mdx +++ b/app/entities/instance-metadata/page.mdx @@ -17,7 +17,7 @@ Check the entity's documentation page to see if it supports this (it will be not - + This entity does not have an ID. diff --git a/app/entities/note/page.mdx b/app/entities/note/page.mdx index f86e22f..2227f4c 100644 --- a/app/entities/note/page.mdx +++ b/app/entities/note/page.mdx @@ -15,7 +15,7 @@ Notes represent a piece of content on a Versia instance. They can be posted by [ - + Media attachments to the note. May be any format. **Must** be remote. diff --git a/app/entities/page.mdx b/app/entities/page.mdx index ec6fe15..b4bb253 100644 --- a/app/entities/page.mdx +++ b/app/entities/page.mdx @@ -17,7 +17,7 @@ Any field in an entity not marked as `required` may be omitted or set to `null`. - + Unique identifier for the entity. Must be unique within the instance. Can be any string. Max of 512 UTF-8 characters. diff --git a/app/entities/unfollow/page.mdx b/app/entities/unfollow/page.mdx index ab836fa..a155516 100644 --- a/app/entities/unfollow/page.mdx +++ b/app/entities/unfollow/page.mdx @@ -28,7 +28,7 @@ Sometimes, [Users](/entities/user) want to unsubscribe from each other to stop s - + This is a [**Transient Entity**](/entities#transient-entities) and does not have a URI. diff --git a/app/entities/user/page.mdx b/app/entities/user/page.mdx index a7dac8d..f3141d1 100644 --- a/app/entities/user/page.mdx +++ b/app/entities/user/page.mdx @@ -42,7 +42,7 @@ Instance **must** be the host of the instance the user is on (hostname with opti - + The user's avatar. Must be an image format (`image/*`). diff --git a/app/extensions/custom-emojis/page.mdx b/app/extensions/custom-emojis/page.mdx index c9cf810..f6d3a18 100644 --- a/app/extensions/custom-emojis/page.mdx +++ b/app/extensions/custom-emojis/page.mdx @@ -11,7 +11,7 @@ The Custom Emojis extension adds support for adding personalized emojis to feder - + Emoji name, surrounded by identification characters (for example, colons: `:happy_face:`). @@ -72,7 +72,7 @@ Custom Emojis can be added to any entity with text content. The extension ID is - + [Custom emojis](/extensions/custom-emoji#structure-definition) to be added to the note. diff --git a/app/extensions/groups/page.mdx b/app/extensions/groups/page.mdx index e0fdca8..5a41f78 100644 --- a/app/extensions/groups/page.mdx +++ b/app/extensions/groups/page.mdx @@ -13,7 +13,7 @@ Refer to [Note](/entities/note#entity-definition)'s `group` property for how not - + Must be `pub.versia:groups/Group`. @@ -84,7 +84,7 @@ Indicates that a [User](/entities/user) wishes to subscribe to a group. - + Must be `pub.versia:groups/Subscribe`. @@ -121,7 +121,7 @@ Indicates that a [User](/entities/user) wishes to unsubscribe from a group. - + Must be `pub.versia:groups/Unsubscribe`. @@ -158,7 +158,7 @@ Indicates that a [Group](#entity-definition) has accepted a [User](/entities/use - + Must be `pub.versia:groups/SubscribeAccept`. @@ -195,7 +195,7 @@ Indicates that a [Group](#entity-definition) has rejected a [User](/entities/use - + Must be `pub.versia:groups/SubscribeReject`. @@ -240,7 +240,7 @@ The `GroupFederate` entity allows a group to federate a note to all of its membe - + Must be `pub.versia:groups/Federate`. diff --git a/app/extensions/instance-messaging/page.mdx b/app/extensions/instance-messaging/page.mdx index 1f44b81..794d1a7 100644 --- a/app/extensions/instance-messaging/page.mdx +++ b/app/extensions/instance-messaging/page.mdx @@ -29,7 +29,7 @@ This extension adds the following metadata to instances: - + The endpoint to send federation debug messages to. diff --git a/app/extensions/interaction-controls/page.mdx b/app/extensions/interaction-controls/page.mdx index 5e8eae0..96bbeea 100644 --- a/app/extensions/interaction-controls/page.mdx +++ b/app/extensions/interaction-controls/page.mdx @@ -40,7 +40,7 @@ The entity defined in this document must be inserted in the `pub.versia:interact - + Describes permissions for a specific interaction. diff --git a/app/extensions/likes/page.mdx b/app/extensions/likes/page.mdx index 569360e..403e6e7 100644 --- a/app/extensions/likes/page.mdx +++ b/app/extensions/likes/page.mdx @@ -18,7 +18,7 @@ Likes are a way for users to show appreciation for a note, like Twitter's "heart - + Must be `pub.versia:likes/Like`. @@ -55,7 +55,7 @@ Dislikes are a way for users to show disapproval for a note, like YouTube's "dis - + Must be `pub.versia:likes/Dislike`. diff --git a/app/extensions/migration/page.mdx b/app/extensions/migration/page.mdx index d775427..b52376b 100644 --- a/app/extensions/migration/page.mdx +++ b/app/extensions/migration/page.mdx @@ -32,7 +32,7 @@ Migration happens in three steps: - + This is a [**Transient Entity**](/entities#transient-entities) and does not have a URI. @@ -69,7 +69,7 @@ The following extensions to [User](/entities/user) are used by the migration ext - + If this user has migrated from another instance, this property **MUST** be set to the URI of the user on the previous instance. diff --git a/app/extensions/page.mdx b/app/extensions/page.mdx index 36e126b..d3ba1f3 100644 --- a/app/extensions/page.mdx +++ b/app/extensions/page.mdx @@ -44,7 +44,7 @@ Extensions can be found in two places: an [Entity](/entities#entity-definition)' - + Custom extensions to the entity. @@ -85,7 +85,7 @@ Extensions can be found in two places: an [Entity](/entities#entity-definition)' - + The extension type. [Must follow naming conventions](#naming). diff --git a/app/extensions/polls/page.mdx b/app/extensions/polls/page.mdx index 71e8209..cb671a7 100644 --- a/app/extensions/polls/page.mdx +++ b/app/extensions/polls/page.mdx @@ -19,7 +19,7 @@ Note that there is no `question` field: the question should be included in the ` - + Array of options for the poll. Each option is a [ContentFormat](/structures/content-format) that can contain the same properties as a Note's `content` (e.g. [Custom Emojis](/extensions/custom-emojis) or HTML hyperlinks). @@ -98,7 +98,7 @@ If a vote is cast to a poll that is closed, the vote should be rejected with a ` - + Must be `pub.versia:polls/Vote`. diff --git a/app/extensions/reactions/page.mdx b/app/extensions/reactions/page.mdx index 035dccc..eaad613 100644 --- a/app/extensions/reactions/page.mdx +++ b/app/extensions/reactions/page.mdx @@ -15,7 +15,7 @@ User reactions are (like every other entity) federated to all followers, and can - + Must be `pub.versia:reactions/Reaction`. diff --git a/app/extensions/reports/page.mdx b/app/extensions/reports/page.mdx index e119796..a1bf22e 100644 --- a/app/extensions/reports/page.mdx +++ b/app/extensions/reports/page.mdx @@ -13,7 +13,7 @@ When an instance receives a report, it *should* be reviewed by a moderator or ad - + This is a [**Transient Entity**](/entities#transient-entities) and does not have a URI. diff --git a/app/extensions/share/page.mdx b/app/extensions/share/page.mdx index 7e2e328..fa38799 100644 --- a/app/extensions/share/page.mdx +++ b/app/extensions/share/page.mdx @@ -17,7 +17,7 @@ When a user shares a note, the note's original author **must** receive the entit - + Must be `pub.versia:share/Share`. diff --git a/app/extensions/vanity/page.mdx b/app/extensions/vanity/page.mdx index f63d45e..07e48d8 100644 --- a/app/extensions/vanity/page.mdx +++ b/app/extensions/vanity/page.mdx @@ -14,7 +14,7 @@ All properties are optional. - + Overlay images to be placed on top of the user's avatar, like this: [example overlay from Discord](https://cdn.discordapp.com/avatar-decoration-presets/a_949a575b693c81ced8f56a7579d0969f.png). diff --git a/app/extensions/websockets/page.mdx b/app/extensions/websockets/page.mdx index b2f21a5..ab29a30 100644 --- a/app/extensions/websockets/page.mdx +++ b/app/extensions/websockets/page.mdx @@ -22,7 +22,7 @@ Messages sent over the WebSocket connection are JSON objects. - + Same as the `Versia-Signature` header in HTTP requests. diff --git a/app/federation/http/page.mdx b/app/federation/http/page.mdx index 47f4dc0..bb421ad 100644 --- a/app/federation/http/page.mdx +++ b/app/federation/http/page.mdx @@ -14,7 +14,7 @@ ALL kinds of HTTP requests/responses between instances **MUST** include a [Signa - + Must include `application/json`. @@ -61,7 +61,7 @@ IETF draft [draft-polli-ratelimit-headers-02](https://www.ietf.org/archive/id/dr - + Must include `application/json; charset=utf-8`. diff --git a/app/links/page.mdx b/app/links/page.mdx index 387d72b..2d76b78 100644 --- a/app/links/page.mdx +++ b/app/links/page.mdx @@ -12,7 +12,7 @@ Versia Links are a way to reference entities in the Versia Protocol, in a way th - + Must be `web+versia://` so that browsers and applications can recognize it. diff --git a/app/structures/collection/page.mdx b/app/structures/collection/page.mdx index 8af34c0..841b87a 100644 --- a/app/structures/collection/page.mdx +++ b/app/structures/collection/page.mdx @@ -17,7 +17,7 @@ Pages should be limited to a reasonable number of entities, such as 20 or 80. - + Author of the collection. Usually the user who owns the collection. [Can be set to `null` to represent the instance](/entities/instance-metadata#the-null-author). @@ -88,7 +88,7 @@ URI Collections are identical to regular collections, but they contain only URIs - + Author of the collection. Usually the user who owns the collection. [Can be set to `null` to represent the instance](/entities/instance-metadata#the-null-author). diff --git a/app/structures/content-format/page.mdx b/app/structures/content-format/page.mdx index 21226d5..b294f93 100644 --- a/app/structures/content-format/page.mdx +++ b/app/structures/content-format/page.mdx @@ -71,7 +71,7 @@ It is a good idea to provide at least two versions of an image (if possible): on - + Structure data. If `Content-Type` is a binary format, this field should be a URI to the binary data. Otherwise, it should be the content itself. Refer to the `remote` property for more information. diff --git a/components/Property.tsx b/components/Property.tsx new file mode 100644 index 0000000..045bfb9 --- /dev/null +++ b/components/Property.tsx @@ -0,0 +1,105 @@ +"use client"; + +import Link from "next/link"; +import { type ReactNode, createContext, useContext } from "react"; + +export const PropertyContext = createContext<{ + name: string; +}>({ + name: "", +}); + +export function Properties({ + children, + name, +}: { children: ReactNode; name: string }) { + return ( +
+
    + + {children} + +
+
+ ); +} + +const numberTypeTooltips = { + f64: "64-bit floating-point number", + i64: "64-bit signed integer", + u64: "64-bit unsigned integer", +}; + +export function Property({ + name, + children, + type, + typeLink, + numberType, + required, +}: { + name: string; + children: ReactNode; + type?: string; + typeLink?: string; + numberType?: "f64" | "i64" | "u64"; + required?: boolean; +}) { + const { name: contextName } = useContext(PropertyContext); + + const idFormat = (name: string) => + name + .toLowerCase() + .replace(/[^a-z0-9]/g, "-") + .replace(/-+/g, "-") + .replace(/^-|-$/g, ""); + + return ( +
  • +
    +
    Name
    +
    + {name} +
    + {required && ( + <> +
    Required
    +
    + Required +
    + + )} + {numberType && ( + <> +
    Type
    +
    + {numberType} +
    + + )} + {type && ( + <> +
    Type
    +
    + {typeLink ? ( + {type} + ) : ( + type + )} +
    + + )} +
    Description
    +
    + {children} +
    +
    +
  • + ); +} diff --git a/components/mdx.tsx b/components/mdx.tsx index 5b925a0..09debe9 100644 --- a/components/mdx.tsx +++ b/components/mdx.tsx @@ -9,6 +9,7 @@ export const a = Link; // biome-ignore lint/performance/noBarrelFile: export { Button } from "./Button"; export { CodeGroup, Code as code, Pre as pre } from "./Code"; +export { Property, Properties } from "./Property"; export function wrapper({ children }: { children: ReactNode }) { return ( @@ -80,81 +81,3 @@ export function Col({ ); } - -export function Properties({ children }: { children: ReactNode }) { - return ( -
    -
      - {children} -
    -
    - ); -} - -const numberTypeTooltips = { - f64: "64-bit floating-point number", - i64: "64-bit signed integer", - u64: "64-bit unsigned integer", -}; - -export function Property({ - name, - children, - type, - typeLink, - numberType, - required, -}: { - name: string; - children: ReactNode; - type?: string; - typeLink?: string; - numberType?: "f64" | "i64" | "u64"; - required?: boolean; -}) { - return ( -
  • -
    -
    Name
    -
    - {name} -
    - {required && ( - <> -
    Required
    -
    - Required -
    - - )} - {numberType && ( - <> -
    Type
    -
    - {numberType} -
    - - )} - {type && ( - <> -
    Type
    -
    - {typeLink ? ( - {type} - ) : ( - type - )} -
    - - )} -
    Description
    -
    - {children} -
    -
    -
  • - ); -}