Skip to content

Commit dff7503

Browse files
committed
checkLinks: use frontmatter for changelog anchors
1 parent e39e358 commit dff7503

File tree

6 files changed

+31
-5
lines changed

6 files changed

+31
-5
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/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-message-interaction-metadata-structure) | [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-message-interaction-metadata-structure) | [In preview](#DOCS_CHANGE_LOG/userinstallable-apps-preview). 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)