Skip to content

Commit b941a3a

Browse files
authored
Cleanup docusaurus config (#2027)
And ensure linter is actually running on it ## Checklist - [-] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [-] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [-] I have not broken the cheatsheet
1 parent 2603f74 commit b941a3a

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"fix:syncpack": "pnpm syncpack fix-mismatches",
1313
"init-vscode-sandbox": "pnpm --filter=@cursorless/cursorless-vscode init-launch-sandbox",
1414
"lint:meta": "pnpm run meta-updater:base --test",
15-
"lint:ts": "eslint packages --ext ts,tsx",
15+
"lint:ts": "eslint packages --ext ts,tsx,mts",
1616
"lint": "pnpm run lint:meta && syncpack list-mismatches && pnpm run lint:ts",
1717
"meta-updater:base": "pnpm --filter=@cursorless/meta-updater build && meta-updater",
1818
"preinstall": "npx only-allow pnpm",

packages/cursorless-org-docs/docusaurus.config.mts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import type { Config } from "@docusaurus/types";
22
import type { Root } from "mdast";
3-
import { relative, resolve } from "path";
3+
import { dirname, relative, resolve } from "path";
44
import { themes } from "prism-react-renderer";
5-
import * as unified from "unified";
5+
import type { Transformer } from "unified";
66
import { visit } from "unist-util-visit";
7+
import { createRequire } from "node:module";
8+
import { fileURLToPath } from "node:url";
9+
10+
const require = createRequire(import.meta.url);
711

812
/**
913
* Files within /docs reference repository directories
@@ -17,24 +21,27 @@ import { visit } from "unist-util-visit";
1721
* - Try resolving it relative to repo root.
1822
* - If anywhere but /docs - link to GitHub.
1923
*/
20-
function remarkPluginFixLinksToRepositoryArtifacts() {
21-
const transformer: unified.Transformer<Root> = async (ast, file) => {
24+
function remarkPluginFixLinksToRepositoryArtifacts(): Transformer<Root> {
25+
return (ast, file) => {
2226
visit(ast, "link", (node) => {
23-
const link = node.url;
24-
if (link.startsWith("http://") || link.startsWith("https://")) {
27+
const { url } = node;
28+
if (url.startsWith("http://") || url.startsWith("https://")) {
2529
return;
2630
}
2731

2832
// Docusaurus runs this plugin on its intermediate
2933
// markdown representaiton as well as on our original files.
3034
// These are relative links that docusaurus already figured out
3135
// based on realative links to .md files
32-
if (link.startsWith("/docs/")) {
36+
if (url.startsWith("/docs/")) {
3337
return;
3438
}
3539

36-
const repoRoot = resolve(__dirname, "../..");
37-
const artifact = resolve(file.dirname!, link);
40+
const repoRoot = resolve(
41+
dirname(fileURLToPath(import.meta.url)),
42+
"../..",
43+
);
44+
const artifact = resolve(file.dirname!, url);
3845
const artifactRelative = relative(repoRoot, artifact);
3946

4047
// We host all files under docs, will resolve as a relative link
@@ -49,7 +56,6 @@ function remarkPluginFixLinksToRepositoryArtifacts() {
4956
node.url = linkToRepositoryArtifact;
5057
});
5158
};
52-
return transformer;
5359
}
5460

5561
const config: Config = {

0 commit comments

Comments
 (0)