Skip to content

Commit 5c4fb30

Browse files
committed
tidying up
1 parent 02576c7 commit 5c4fb30

22 files changed

+34
-97
lines changed

app/routes/ApiRoute.res

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ let loader: ReactRouter.Loader.t<loaderData> = async args => {
111111
| _ => parseApi(await Node.Fs.readFile("./markdown-pages/docs/api/stdlib.json", "utf-8"))
112112
}
113113

114-
let stdlibToc = apiDocs->Dict.get(basePath)
115-
116114
let toctree = groupItems(apiDocs)
117115

118116
let data = {

app/routes/SyntaxLookupRoute.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let convert = (mdx: Mdx.attributes): SyntaxLookup.item => {
1515
}
1616
}
1717

18-
let loader: Loader.t<loaderData> = async ({request}) => {
18+
let loader: Loader.t<loaderData> = async _ => {
1919
let allMdx = await Shims.runWithoutLogging(() => loadAllMdx())
2020

2121
let mdxSources =

patches/react-router-mdx+1.0.8.patch

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
diff --git a/node_modules/react-router-mdx/dist/server/index.js b/node_modules/react-router-mdx/dist/server/index.js
2-
index 1e56a6c..5f08c1c 100644
2+
index 1e56a6c..b323b05 100644
33
--- a/node_modules/react-router-mdx/dist/server/index.js
44
+++ b/node_modules/react-router-mdx/dist/server/index.js
5-
@@ -59,15 +59,16 @@ import matter from "gray-matter";
5+
@@ -59,15 +59,15 @@ import matter from "gray-matter";
66
import { compile as compileMdx } from "@mdx-js/mdx";
77
import remarkFrontmatter from "remark-frontmatter";
88
var compile = async (content, options) => {
99
- const compiled = await compileMdx(content, {
10-
+ // TODO: open a PR to add in the path!
1110
+ const compiled = await compileMdx({ value: content, path: options?.path }, {
1211
...options ?? {},
1312
outputFormat: "function-body",
@@ -23,11 +22,9 @@ index 1e56a6c..5f08c1c 100644
2322
return attributes;
2423
};
2524

26-
@@ -118,13 +119,15 @@ var loadMdx = async (request, options) => {
27-
const aliases = getAliases(getOptions());
25+
@@ -119,12 +119,13 @@ var loadMdx = async (request, options) => {
2826
const path = getFilePathBasedOnUrl(request.url, paths, aliases);
2927
const content = await getFileContent(path);
30-
+ console.log({ path })
3128
const [mdxContent, attributes] = await Promise.all([
3229
- compile(content, options),
3330
+ compile(content, { ...options, path }),

scripts/generate_llms.res

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ let createSmallFile = (content: string, filePath: string): unit => {
6868
Node.Fs.appendFileSync(filePath, smallContent, "utf8")
6969
}
7070

71-
let createLlmsFiles = (version: string, docsDirectory: string, llmsDirectory: string): unit => {
71+
// TODO: post RR7 - refactor to remove the version parameter, as it's unused
72+
let createLlmsFiles = (_version: string, docsDirectory: string, llmsDirectory: string): unit => {
7273
let mdxFileTemplatePath = llmsDirectory->Node.Path.join2("template.mdx")
7374
let mdxFilePath = docsDirectory->Node.Path.join2("llms.mdx")
7475
let txtFileTemplatePath = llmsDirectory->Node.Path.join2("template.txt")

src/ApiDocs.res

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,6 @@ module SidebarTree = {
128128
// This is the full path to this module, e.g. "/docs/manual/api/stdlib/array" or "/docs/manual/api/stdlib/int"
129129
let fullPath = `${moduleRoute}/${relativePath}`->Url.normalizePath
130130

131-
let parentPath = switch node.path->Array.join("/")->Url.normalizePath {
132-
| "" => None
133-
| path => Some(path)
134-
}
135-
136131
let isCurrentRoute = fullPath == (location.pathname :> string)
137132

138133
let classNameActive = isCurrentRoute ? classNameActive : ""
@@ -181,12 +176,6 @@ module SidebarTree = {
181176
}
182177
}
183178

184-
let {pathname} = ReactRouter.useLocation()
185-
186-
let url = (pathname :> string)->Url.parse->Some
187-
188-
let onChange = evt => ()
189-
190179
let preludeSection =
191180
<div className="flex justify-between text-fire font-medium items-baseline">
192181
<VersionSelect />
@@ -301,11 +290,6 @@ let make = (props: props) => {
301290

302291
let toggleSidebar = () => setSidebarOpen(prev => !prev)
303292

304-
let title = switch props {
305-
| Ok({module_: {id}}) => id
306-
| _ => "API"
307-
}
308-
309293
let children = {
310294
open Markdown
311295
switch props {
@@ -402,8 +386,6 @@ module Data = {
402386
let getVersion = (~moduleName: string) => {
403387
open Node
404388

405-
let pathModule = Path.join([dir, `${moduleName}.json`])
406-
407389
let moduleContent =
408390
Fs.readFileSync(`markdown-pages/docs/api/${moduleName}.json`)->JSON.parseOrThrow
409391

src/Blog.res

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,6 @@ let make = (~posts: array<BlogApi.post>, ~category: category): React.element =>
257257
</>
258258
}
259259

260-
let (isOverlayOpen, setOverlayOpen) = React.useState(() => false)
261-
262260
<>
263261
<div className="mt-16 pt-2">
264262
<div className="text-gray-80 text-18">

src/BlogArticle.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ module BlogHeader = {
101101
}
102102

103103
let make = (props: props) => {
104-
let {children, isArchived, path, frontmatter} = props
104+
let {children, isArchived, frontmatter} = props
105105

106106
let archivedNote = isArchived
107107
? {

src/Mdx.res

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,16 @@ let remarkReScriptPrelude = tree => {
129129
let remarkLinkPlugin = (tree, vfile) => {
130130
visit(tree, "link", node => {
131131
let url = node["url"]
132-
let filePath =
133-
vfile["history"][0]->Option.getOrThrow(
134-
~message=`File path not found for vfile: ${JSON.stringifyAny(vfile)->Option.getOr(
135-
"unknown vfile",
136-
)}`,
132+
133+
// The dev server behaves differently than production builds, so we need to not fail here
134+
let filePath = switch (vfile["history"][0], Env.dev) {
135+
| (Some(path), _) => path
136+
| (None, false) =>
137+
JsExn.throw(
138+
`File path not found for vfile: ${JSON.stringifyAny(vfile)->Option.getOr("unknown vfile")}`,
137139
)
140+
| (None, true) => ""
141+
}
138142

139143
// Direct links to the homepage are OK
140144
if url == "https://rescript-lang.org" {

src/Packages.res

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,7 @@ let make = (props: props) => {
399399
</Category>
400400
}
401401

402-
let location = ReactRouter.useLocation()
403-
let (searchParams, setSearchParams) = ReactRouter.useSearchParams()
402+
let (_, setSearchParams) = ReactRouter.useSearchParams()
404403

405404
// On first render, the router query is undefined so we set a flag.
406405
let firstRenderDone = React.useRef(false)
@@ -422,7 +421,6 @@ let make = (props: props) => {
422421
None
423422
}, [state])
424423

425-
let (isOverlayOpen, setOverlayOpen) = React.useState(() => false)
426424
<>
427425
<Meta
428426
siteName="ReScript Packages"

src/Playground.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,7 @@ let initialReContent = `Js.log("Hello Reason 3.6!");`
15031503

15041504
@react.component
15051505
let make = (~bundleBaseUrl: string, ~versions: array<string>) => {
1506-
let (searchParams, setSearchParams) = ReactRouter.useSearchParams()
1506+
let (searchParams, _) = ReactRouter.useSearchParams()
15071507

15081508
let versions =
15091509
versions

0 commit comments

Comments
 (0)