Skip to content

Commit 40a0f3f

Browse files
colinloretzmazylol
authored andcommitted
Fix changelog link checker + changelog links (discord#7254)
* checkLinks: use frontmatter for changelog anchors * Fix entitlement migration links * link to 'in preview' no longer relevant * Tables 🙃
1 parent 896ab89 commit 40a0f3f

File tree

8 files changed

+35
-9
lines changed

8 files changed

+35
-9
lines changed

docs/change_log/2024-06-27-user-installed-apps-general-availability.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ date: "2024-06-27"
44
breaking: true
55
---
66

7-
Back in March, we announced [the beta for user-installed apps](#DOCS_CHANGE_LOG/user-installable-apps-preview). After listening and making updates based on feedback from developers and modmins, we're excited to announce that user-installed apps are now considered generally available and can be used in all servers (regardless of size).
7+
Back in March, we announced [the beta for user-installed apps](#DOCS_CHANGE_LOG/userinstallable-apps-preview). After listening and making updates based on feedback from developers and modmins, we're excited to announce that user-installed apps are now considered generally available and can be used in all servers (regardless of size).
88

99
With this update, there are a few API and behavioral updates for user-installed apps.
1010

docs/change_log/2024-10-04-updates-to-entitlement-migration-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ We updated our previous entitlement migration guide to provide more up-to-date i
1515
- The `ends_at` value on the [entitlement object](#DOCS_RESOURCES_ENTITLEMENT/entitlement-object) is set when the subscription ends.
1616
- To receive the value of when a subscription was canceled, you should listen for the `SUBSCRIPTION_UPDATE` events or use the [Subscription API](#DOCS_RESOURCES_SUBSCRIPTION).
1717

18-
View the [updated migration guide](#DOCS_CHANGE_LOG/subscription-api-and-entitlement-migration).
18+
View the [updated migration guide](#DOCS_CHANGE_LOG/premium-apps-entitlement-migration-and-new-subscription-api).
1919

2020
To see a full diff of the changes, refer to this pull request: [Entitlement Migration Guide Updates](https://github.com/discord/discord-api-docs/pull/7201).

docs/events/Gateway_Events.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ Sent when an entitlement is created. The inner payload is an [entitlement](#DOCS
592592
#### Entitlement Update
593593

594594
> danger
595-
> Starting on October 1, 2024, the `ENTITLEMENT_UPDATE` event behavior will be changing. You will no longer receive an `ENTITLEMENT_UPDATE` event on successful renewal When a user cancels, you will receive an `ENTITLEMENT_UPDATE` events with an `ends_at` value when the subscription ends. See the [Change Log and Entitlement Migration Guide](#DOCS_CHANGE_LOG/subscription-api-and-entitlement-migration) for more information.
595+
> Starting on October 1, 2024, the `ENTITLEMENT_UPDATE` event behavior will be changing. You will no longer receive an `ENTITLEMENT_UPDATE` event on successful renewal When a user cancels, you will receive an `ENTITLEMENT_UPDATE` events with an `ends_at` value when the subscription ends. See the [Change Log and Entitlement Migration Guide](#DOCS_CHANGE_LOG/premium-apps-entitlement-migration-and-new-subscription-api) for more information.
596596
597597
Sent when an entitlement is updated. The inner payload is an [entitlement](#DOCS_RESOURCES_ENTITLEMENT/entitlement-object) object.
598598

docs/monetization/Implementing_App_Subscriptions.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ When creating subscriptions, you will need to choose between user or guild subsc
1919
## How App Subscriptions Work
2020

2121
> danger
22-
> **Starting on October 1st, 2024**, the`ENTITLEMENT_CREATE` and `ENTITLEMENT_UPDATE` event behavior described below is changing. Please see the [Change Log and Entitlement Migration Guide](#DOCS_CHANGE_LOG/subscription-api-and-entitlement-migration) for more information on what is changing and how to prepare.
22+
> **Starting on October 1st, 2024**, the`ENTITLEMENT_CREATE` and `ENTITLEMENT_UPDATE` event behavior described below is changing. Please see the [Change Log and Entitlement Migration Guide](#DOCS_CHANGE_LOG/premium-apps-entitlement-migration-and-new-subscription-api) for more information on what is changing and how to prepare.
2323
2424
- When a user purchases your subscription SKU, Discord creates an [Entitlement](#DOCS_RESOURCES_ENTITLEMENT) for the user (or guild) and that specific Subscription [SKU](#DOCS_RESOURCES_SKU).
2525
- You will receive an `ENTITLEMENT_CREATE` event via the Gateway.
@@ -39,7 +39,7 @@ When creating subscriptions, you will need to choose between user or guild subsc
3939
- When a user cancels their subscription, your app will not receive any entitlement events.
4040
- When a subscription ends, the entitlement to the subscription will end. Developers will receive an `ENTITLEMENT_UPDATE` event with an `ends_at` timestamp indicating when the subscription ended.
4141

42-
Please see the [Change Log and Entitlement Migration Guide](#DOCS_CHANGE_LOG/subscription-api-and-entitlement-migration) for more information on what is changing and how to prepare.
42+
Please see the [Change Log and Entitlement Migration Guide](#DOCS_CHANGE_LOG/premium-apps-entitlement-migration-and-new-subscription-api) for more information on what is changing and how to prepare.
4343

4444
### Using Subscription Events for the Subscription Lifecycle
4545

@@ -73,7 +73,7 @@ Depending on your app's features, you can use a combination of [Gateway events](
7373
### Accessing Entitlements with Gateway Events
7474

7575
> danger
76-
> **Starting on October 1, 2024**, the `ENTITLEMENT_CREATE` and `ENTITLEMENT_UPDATE` event behavior described below is changing. Please see the [Change Log and Entitlement Migration Guide](#DOCS_CHANGE_LOG/subscription-api-and-entitlement-migration) for more information on what is changing and how to prepare. The docs will be updated on November 1, 2024 to reflect the new behavior.
76+
> **Starting on October 1, 2024**, the `ENTITLEMENT_CREATE` and `ENTITLEMENT_UPDATE` event behavior described below is changing. Please see the [Change Log and Entitlement Migration Guide](#DOCS_CHANGE_LOG/premium-apps-entitlement-migration-and-new-subscription-api) for more information on what is changing and how to prepare. The docs will be updated on November 1, 2024 to reflect the new behavior.
7777
7878
When users subscribe or renew a subscription with your app, Discord will emit [Entitlement Gateway events](#DOCS_EVENTS_GATEWAY_EVENTS/entitlements).
7979

docs/resources/Message.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Represents a message sent in a channel within Discord.
4343
| message_reference? | [message reference](#DOCS_RESOURCES_MESSAGE/message-reference-structure) object | data showing the source of a crosspost, channel follow add, pin, or reply message |
4444
| message_snapshots? \[5\] | array of [message snapshot](#DOCS_RESOURCES_MESSAGE/message-snapshot-object) objects | the message associated with the `message_reference`. This is a minimal subset of fields in a message (e.g. `author` is excluded.) |
4545
| referenced_message? \[4\] | ?[message object](#DOCS_RESOURCES_MESSAGE/message-object) | the message associated with the message_reference |
46-
| interaction_metadata? | [message interaction metadata object](#DOCS_RESOURCES_MESSAGE/message-interaction-metadata-object) | [In preview](#DOCS_CHANGE_LOG/user-installable-apps-preview). Sent if the message is sent as a result of an [interaction](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/) |
46+
| interaction_metadata? | [message interaction metadata object](#DOCS_RESOURCES_MESSAGE/message-interaction-metadata-object) | Sent if the message is sent as a result of an [interaction](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/) |
4747
| interaction? | [message interaction object](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/message-interaction-object-message-interaction-structure) | **Deprecated in favor of `interaction_metadata`**; sent if the message is a response to an [interaction](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/) |
4848
| thread? | [channel](#DOCS_RESOURCES_CHANNEL/channel-object) object | the thread that was started from this message, includes [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) object |
4949
| components? \[2\] | array of [message components](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/component-object) | sent if the message contains components like buttons, action rows, or other interactive components |

package-lock.json

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@
3434
"@eslint/js": "^9.2.0",
3535
"@mdx-js/mdx": "^3.0.1",
3636
"@mdx-js/react": "^3.0.1",
37+
"@types/js-yaml": "^4.0.9",
3738
"@types/node": "^20.12.12",
3839
"chalk": "^5.3.0",
3940
"eslint": "^9.2.0",
4041
"eslint-config-prettier": "^9.1.0",
4142
"eslint-plugin-prettier": "^5.1.3",
43+
"js-yaml": "^4.1.0",
4244
"markdown-table-formatter": "^1.6.0",
4345
"mdast-util-from-markdown": "^2.0.1",
4446
"mdast-util-to-markdown": "^2.1.0",

tools/checkLinks.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@ import { readdirSync, statSync, readFileSync } from "node:fs";
22
import path from "node:path";
33
import chalk from "chalk";
44
import * as github from "@actions/core";
5+
import * as yaml from "js-yaml";
56
const cwd = process.env.GITHUB_ACTIONS ? process.env.GITHUB_WORKSPACE! : process.cwd();
67

8+
interface Frontmatter {
9+
title?: string;
10+
date?: string;
11+
breaking: boolean;
12+
}
13+
714
function importDirectory(directory: string, extensions: string[], subdirectories = true) {
815
try {
916
const output = new Map<string, string>();
@@ -110,7 +117,17 @@ for (const [name, raw] of docFiles) {
110117
// This collects all potential change-log pages, and adds them to the list of
111118
// available anchors under `/change_log`.
112119
if (name.startsWith("/change_log/")) {
113-
changelogAnchors.push(name.split("/")[2].slice(11));
120+
const frontmatter = raw.split("---")[1];
121+
const parsedFrontmatter = yaml.load(frontmatter) as Frontmatter;
122+
const title = parsedFrontmatter?.title;
123+
if (title) {
124+
const anchor = title
125+
.replace(/[^ A-Z0-9]/gi, "")
126+
.trim()
127+
.replace(/ +/g, "-")
128+
.toLowerCase();
129+
changelogAnchors.push(anchor);
130+
}
114131
}
115132

116133
let parentAnchor = "";

0 commit comments

Comments
 (0)