From 5e0dd7de4fc76191d3ac5fa46c32d9d07d4e1f25 Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Wed, 15 Nov 2023 00:13:28 +0100 Subject: [PATCH] Integrate genType as 'TypeScript Interop' chapter into main docs --- data/sidebar_manual_latest.json | 6 ++ misc_docs/syntax/decorator_gentype.mdx | 49 ++------------- next.config.mjs | 62 +++++++++++++------ .../manual/latest/build-configuration.mdx | 2 +- .../latest/gentype-getting-started.mdx} | 4 +- .../latest/gentype-introduction.mdx} | 6 +- .../latest/gentype-supported-types.mdx} | 16 ++--- .../latest/gentype-usage.mdx} | 8 ++- .../docs/manual/latest/shared-data-types.mdx | 2 +- .../manual/v10.0.0/build-configuration.mdx | 2 +- .../manual/v9.0.0/build-configuration.mdx | 2 +- pages/docs/react/latest/introduction.mdx | 2 +- pages/docs/react/v0.10.0/introduction.mdx | 2 +- pages/docs/react/v0.11.0/introduction.mdx | 2 +- scripts/extract-tocs.mjs | 27 -------- src/DocsOverview.res | 2 +- src/common/App.res | 2 - src/common/Constants.res | 2 +- src/components/Navigation.res | 12 ++-- src/layouts/GenTypeDocsLayout.res | 46 -------------- src/layouts/GenTypeDocsLayout.resi | 6 -- src/layouts/LandingPageLayout.res | 2 +- 22 files changed, 90 insertions(+), 174 deletions(-) rename pages/docs/{gentype/latest/getting-started.mdx => manual/latest/gentype-getting-started.mdx} (98%) rename pages/docs/{gentype/latest/introduction.mdx => manual/latest/gentype-introduction.mdx} (94%) rename pages/docs/{gentype/latest/supported-types.mdx => manual/latest/gentype-supported-types.mdx} (92%) rename pages/docs/{gentype/latest/usage.mdx => manual/latest/gentype-usage.mdx} (96%) delete mode 100644 src/layouts/GenTypeDocsLayout.res delete mode 100644 src/layouts/GenTypeDocsLayout.resi diff --git a/data/sidebar_manual_latest.json b/data/sidebar_manual_latest.json index 6cdeca5d8..e0f242847 100644 --- a/data/sidebar_manual_latest.json +++ b/data/sidebar_manual_latest.json @@ -54,6 +54,12 @@ "browser-support-polyfills", "libraries" ], + "TypeScript Interop": [ + "gentype-introduction", + "gentype-getting-started", + "gentype-usage", + "gentype-supported-types" + ], "Build System": [ "build-overview", "build-configuration", diff --git a/misc_docs/syntax/decorator_gentype.mdx b/misc_docs/syntax/decorator_gentype.mdx index 226678143..52f976187 100644 --- a/misc_docs/syntax/decorator_gentype.mdx +++ b/misc_docs/syntax/decorator_gentype.mdx @@ -1,20 +1,18 @@ --- id: "gentype-decorator" -keywords: ["gentype", "decorator", "typescript", "flow"] +keywords: ["gentype", "decorator", "typescript"] name: "@genType" summary: "This is the `@genType` decorator." category: "decorators" --- -The `@genType` decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems. +The `@genType` decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, or plain JavaScript codebases, without losing type information across different type systems. -[GenType](/docs/gentype/latest/introduction) is a code generation tool for automatically generating [TypeScript](https://www.typescriptlang.org/) / [Flow](https://flow.org/) type definitions, and JS runtime converters for non-shared ReScript values. It also features first-class support for [ReasonReact](https://reasonml.github.io/reason-react/) components. - -**Note:** This decorator requires the `gentype` npm package to be installed and configured correctly. Please refer to genType's [Getting Started](/docs/gentype/latest/getting-started) section for more details. +[GenType](/docs/manual/latest/gentype-introduction) is a code generation tool for automatically generating [TypeScript](https://www.typescriptlang.org/) type definitions, and JS runtime converters for non-shared ReScript values. It also features first-class support for [rescript-react](/docs/react/latest/introduction) components. ### Example - + ```res @genType @@ -59,45 +57,8 @@ export const make: React.ComponentType<{ }; ``` -```js -/** - * @flow strict - * @generated from MyComponent.res - * @nolint - */ -/* eslint-disable */ -// $FlowExpectedError: Reason checked type sufficiently -type $any = any; - -// $FlowExpectedError: Reason checked type sufficiently -import * as React from "react"; - -const $$toRE818596289 = { Red: 0, Blue: 1 }; - -// $FlowExpectedError: Reason checked type sufficiently -import * as MyComponentBS from "./MyComponent.bs"; - -export type color = "Red" | "Blue"; - -// Type annotated function components are not checked by Flow, but typeof() works. -const make$$forTypeof = function (_: {| - +color: color, - +name: string, -|}): React$Node { - return null; -}; - -export type Props = {| +color: color, +name: string |}; - -export const make: typeof make$$forTypeof = function MyComponent(Arg1: $any) { - const $props = { color: $$toRE818596289[Arg1.color], name: Arg1.name }; - const result = React.createElement(MyComponentBS.make, $props); - return result; -}; -``` - ### References -* [GenType](/docs/gentype/latest/introduction) +* [GenType](/docs/manual/latest/gentype-introduction) diff --git a/next.config.mjs b/next.config.mjs index 14fc00747..356759d25 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,13 +1,13 @@ import fs from "fs"; import webpack from "webpack"; -import rehypeSlug from 'rehype-slug'; -import remarkGfm from 'remark-gfm'; -import remarkComment from 'remark-comment'; -import remarkFrontmatter from 'remark-frontmatter' +import rehypeSlug from "rehype-slug"; +import remarkGfm from "remark-gfm"; +import remarkComment from "remark-comment"; +import remarkFrontmatter from "remark-frontmatter"; import remarkMdxFrontmatter from "remark-mdx-frontmatter"; -import { createLoader } from 'simple-functional-loader' +import { createLoader } from "simple-functional-loader"; -const bsconfig = JSON.parse(fs.readFileSync("./bsconfig.json")) +const bsconfig = JSON.parse(fs.readFileSync("./bsconfig.json")); const { ProvidePlugin } = webpack; @@ -46,10 +46,10 @@ const config = { function mainMdxLoader(plugins) { return [ createLoader(function(source) { - const result = `${source}\n\nMDXContent.frontmatter = frontmatter` - return result + const result = `${source}\n\nMDXContent.frontmatter = frontmatter`; + return result; }), - ] + ]; } config.module.rules.push({ @@ -61,18 +61,22 @@ const config = { test: /\.mdx?$/, use: [ { - loader: '@mdx-js/loader', + loader: "@mdx-js/loader", /** @type {import('@mdx-js/loader').Options} */ options: { - remarkPlugins: [remarkComment, remarkGfm, remarkFrontmatter, remarkMdxFrontmatter], - providerImportSource: '@mdx-js/react', - rehypePlugins: [rehypeSlug] - } - } - ] + remarkPlugins: [ + remarkComment, + remarkGfm, + remarkFrontmatter, + remarkMdxFrontmatter, + ], + providerImportSource: "@mdx-js/react", + rehypePlugins: [rehypeSlug], + }, + }, + ], }); - config.plugins.push(new ProvidePlugin({ React: "react" })); return config; }, @@ -93,11 +97,31 @@ const config = { destination: "/docs/manual/v10.0.0/migrate-from-bucklescript-reason", permanent: true, }, + { + source: "/docs/gentype/latest/introduction", + destination: "/docs/manual/latest/gentype-introduction", + permanent: true, + }, + { + source: "/docs/gentype/latest/getting-started", + destination: "/docs/manual/latest/gentype-getting-started", + permanent: true, + }, + { + source: "/docs/gentype/latest/usage", + destination: "/docs/manual/latest/gentype-usage", + permanent: true, + }, + { + source: "/docs/gentype/latest/supported-types", + destination: "/docs/manual/latest/gentype-supported-types", + permanent: true, + }, ]; }, }; export default { transpilePackages: transpileModules, - ...config -} + ...config, +}; diff --git a/pages/docs/manual/latest/build-configuration.mdx b/pages/docs/manual/latest/build-configuration.mdx index ab045f030..8c36b3c10 100644 --- a/pages/docs/manual/latest/build-configuration.mdx +++ b/pages/docs/manual/latest/build-configuration.mdx @@ -161,7 +161,7 @@ Generating JS files with the `.bs.js` suffix means that, on the JS side, you can - It's immediately clear that we're dealing with a generated JS file here. - It avoids clashes with a potential `theFile.js` file in the same folder. - It avoids the need of using a build system loader for ReScript files. This + in-source build means integrating a ReScript project into your pure JS codebase **basically doesn't touch anything in your build pipeline at all**. -- [genType](/docs/gentype/latest/introduction) requires `bs.js` for compiled JS artifacts. If you are using `genType`, you need to use `bs.js` for now. +- [genType](/docs/manual/latest/gentype-introduction) requires `bs.js` for compiled JS artifacts. If you are using `genType`, you need to use `bs.js` for now. ## warnings diff --git a/pages/docs/gentype/latest/getting-started.mdx b/pages/docs/manual/latest/gentype-getting-started.mdx similarity index 98% rename from pages/docs/gentype/latest/getting-started.mdx rename to pages/docs/manual/latest/gentype-getting-started.mdx index b5f6802b8..af463fbff 100644 --- a/pages/docs/gentype/latest/getting-started.mdx +++ b/pages/docs/manual/latest/gentype-getting-started.mdx @@ -1,10 +1,10 @@ --- title: "Getting Started" description: "How to get started with genType in your ReScript projects" -canonical: "/docs/gentype/latest/getting-started" +canonical: "/docs/manual/latest/gentype-getting-started" --- -# Getting Started +# GenType - Getting Started ## Setup diff --git a/pages/docs/gentype/latest/introduction.mdx b/pages/docs/manual/latest/gentype-introduction.mdx similarity index 94% rename from pages/docs/gentype/latest/introduction.mdx rename to pages/docs/manual/latest/gentype-introduction.mdx index eed273bda..2aedbd3ef 100644 --- a/pages/docs/gentype/latest/introduction.mdx +++ b/pages/docs/manual/latest/gentype-introduction.mdx @@ -1,7 +1,7 @@ --- title: "Introduction" -description: "GenType - Interoperability between ReScript and TypeScript / Flow" -canonical: "/docs/gentype/latest/introduction" +description: "GenType - Interoperability between ReScript and TypeScript" +canonical: "/docs/manual/latest/gentype-introduction" --- # GenType @@ -98,7 +98,7 @@ const App = () => { That's it for our quick example. -For detailed information, head to the [Getting Started](getting-started) or [Usage](usage) section. +For detailed information, head to the [Getting Started](/docs/manual/latest/gentype-getting-started) or [Usage](/docs/manual/latest/gentype-usage) section. ## Development diff --git a/pages/docs/gentype/latest/supported-types.mdx b/pages/docs/manual/latest/gentype-supported-types.mdx similarity index 92% rename from pages/docs/gentype/latest/supported-types.mdx rename to pages/docs/manual/latest/gentype-supported-types.mdx index 7b9624619..187647559 100644 --- a/pages/docs/gentype/latest/supported-types.mdx +++ b/pages/docs/manual/latest/gentype-supported-types.mdx @@ -1,10 +1,10 @@ --- title: "Supported Types" -description: "Supported types and value convertion in GenType" -canonical: "/docs/gentype/latest/supported-types" +description: "Supported types and value conversion in GenType" +canonical: "/docs/manual/latest/gentype-supported-types" --- -# Supported Types +# GenType - Supported Types @@ -39,7 +39,7 @@ The JS values are identical: there is no conversion unless the argument type nee ReScript record values of type e.g. `{x: int}` such as `{x: 0}`, `{x: 1}`, are exported to JS values of type `{x: number}` without runtime conversion. -Since records are immutable by default, their fields will be exported to readonly property types in Flow/TS. Mutable fields are specified in ReScript by e.g. `{mutable mutableField: string}`. +Since records are immutable by default, their fields will be exported to readonly property types in TS. Mutable fields are specified in ReScript by e.g. `{mutable mutableField: string}`. The `@as` annotation can be used to change the name of a field on the JS side of things. So e.g. `{@as("y") x: int}` is exported as JS type `{y: number}`. @@ -50,14 +50,14 @@ If one field of the ReScript record has option type, this is exported to an opti ReScript object values of type e.g. `{. "x":int}` such as `{"x": 0}`, `{"x": 1}`, `{"x": 2}`, are exported as identical JS object values `{x:0}`, `{x:1}`, `{x:2}`. This requires no conversion. So they are exported to JS values of type `{x:number}`. A conversion is required only when the type of some field requires conversions. -Since objects are immutable by default, their fields will be exported to readonly property types in Flow/TS. Mutable fields are specified in ReScript by e.g. `{ @set "mutableField": string }`. +Since objects are immutable by default, their fields will be exported to readonly property types in TS. Mutable fields are specified in ReScript by e.g. `{ @set "mutableField": string }`. It is possible to mix object and option types, so for example the ReScript type `{. "x":int, "y":option}` exports to JS type `{x:number, ?y: string}`, requires no conversion, and allows option pattern matching on the ReScript side. ## Tuples ReScript tuple values of type e.g. `(int, string)` are exported as identical JS values of type `[number, string]`. This requires no conversion, unless one of types of the tuple items does. -While the type of ReScript tuples is immutable, there's currently no mature enforcement in TS/Flow, so they're currenty exported to mutable tuples. +While the type of ReScript tuples is immutable, there's currently no mature enforcement in TS, so they're currenty exported to mutable tuples. ## Variants @@ -96,7 +96,7 @@ Arrays with elements of ReScript type `t` are exported to JS arrays with element Immutable arrays are supported with the additional ReScript library [ImmutableArray.res/.resi](https://github.com/reason-association/genType/tree/master/examples/typescript-react-example/src/ImmutableArray.resi), which currently needs to be added to your project. -The type `ImmutableArray.t<+'a>` is covariant, and is mapped to readonly array types in TS/Flow. As opposed to TS/Flow, `ImmutableArray.t` does not allow casting in either direction with normal arrays. Instead, a copy must be performed using `fromArray` and `toArray`. +The type `ImmutableArray.t<+'a>` is covariant, and is mapped to readonly array types in TS. As opposed to TS, `ImmutableArray.t` does not allow casting in either direction with normal arrays. Instead, a copy must be performed using `fromArray` and `toArray`. ## Functions and Function Components @@ -117,7 +117,7 @@ let make = (~name) => React.string(name); ## Imported Types -It's possible to import an existing TS/Flow type as an opaque type in ReScript. For example, +It's possible to import an existing TS type as an opaque type in ReScript. For example, ```res @genType.import("./SomeFlowTypes") type weekday diff --git a/pages/docs/gentype/latest/usage.mdx b/pages/docs/manual/latest/gentype-usage.mdx similarity index 96% rename from pages/docs/gentype/latest/usage.mdx rename to pages/docs/manual/latest/gentype-usage.mdx index fa61f9502..6e79c1486 100644 --- a/pages/docs/gentype/latest/usage.mdx +++ b/pages/docs/manual/latest/gentype-usage.mdx @@ -1,4 +1,10 @@ -# Usage +--- +title: "Usage" +description: "GenType - Interoperability between ReScript and TypeScript" +canonical: "/docs/manual/latest/gentype-usage" +--- + +# GenType Usage diff --git a/pages/docs/manual/latest/shared-data-types.mdx b/pages/docs/manual/latest/shared-data-types.mdx index 57f4cb687..661ffdbdf 100644 --- a/pages/docs/manual/latest/shared-data-types.mdx +++ b/pages/docs/manual/latest/shared-data-types.mdx @@ -41,4 +41,4 @@ Unlike most compiled-to-js languages, in ReScript, **you don't need to write dat Many of these are stable, which means that you can still serialize/deserialize them as-is without manual conversions. But we discourage actively peeking into their structure otherwise. -These types require manual conversions if you want to export them for JS consumption. For a seamless JS/TypeScript/Flow integration experience, you might want to use [genType](https://github.com/cristianoc/gentype) instead of doing conversions by hand. +These types require manual conversions if you want to export them for JS consumption. For a seamless JS/TypeScript integration experience, you might want to use [genType](https://github.com/cristianoc/gentype) instead of doing conversions by hand. diff --git a/pages/docs/manual/v10.0.0/build-configuration.mdx b/pages/docs/manual/v10.0.0/build-configuration.mdx index debce5225..c1f1e5d9d 100644 --- a/pages/docs/manual/v10.0.0/build-configuration.mdx +++ b/pages/docs/manual/v10.0.0/build-configuration.mdx @@ -161,7 +161,7 @@ Generating JS files with the `.bs.js` suffix means that, on the JS side, you can - It's immediately clear that we're dealing with a generated JS file here. - It avoids clashes with a potential `theFile.js` file in the same folder. - It avoids the need of using a build system loader for ReScript files. This + in-source build means integrating a ReScript project into your pure JS codebase **basically doesn't touch anything in your build pipeline at all**. -- [genType](/docs/gentype/latest/introduction) requires `bs.js` for compiled JS artifacts. If you are using `genType`, you need to use `bs.js` for now. +- [genType](/docs/manual/latest/gentype-introduction) requires `bs.js` for compiled JS artifacts. If you are using `genType`, you need to use `bs.js` for now. ## warnings diff --git a/pages/docs/manual/v9.0.0/build-configuration.mdx b/pages/docs/manual/v9.0.0/build-configuration.mdx index 5122093d0..3cf1ab936 100644 --- a/pages/docs/manual/v9.0.0/build-configuration.mdx +++ b/pages/docs/manual/v9.0.0/build-configuration.mdx @@ -157,7 +157,7 @@ Generating JS files with the `.bs.js` suffix means that, on the JS side, you can - It's immediately clear that we're dealing with a generated JS file here. - It avoids clashes with a potential `theFile.js` file in the same folder. - It avoids the need of using a build system loader for ReScript files. This + in-source build means integrating a ReScript project into your pure JS codebase **basically doesn't touch anything in your build pipeline at all**. -- [genType](/docs/gentype/latest/introduction) requires `bs.js` for compiled JS artifacts. If you are using `genType`, you need to use `bs.js` for now. +- [genType](/docs/manual/latest/gentype-introduction) requires `bs.js` for compiled JS artifacts. If you are using `genType`, you need to use `bs.js` for now. ## warnings diff --git a/pages/docs/react/latest/introduction.mdx b/pages/docs/react/latest/introduction.mdx index 5fab2d8e7..09a225e9b 100644 --- a/pages/docs/react/latest/introduction.mdx +++ b/pages/docs/react/latest/introduction.mdx @@ -18,7 +18,7 @@ All our documented examples can be compiled in our [ReScript Playground](/try) a - Comes with all essential React APIs for building production ready apps (`useState`, `useReducer`, `useEffect`, `useRef`,...) - No component class API (all ReScript & React codebases are built on function components & hooks) - Strong level of type safetiness and type inference for component props and state values -- [GenType](/docs/gentype/latest/introduction) support for importing / exporting React components in TypeScript codebases +- [GenType](/docs/manual/latest/gentype-introduction) support for importing / exporting React components in TypeScript codebases > **This documentation assumes basic knowledge about ReactJS.** > diff --git a/pages/docs/react/v0.10.0/introduction.mdx b/pages/docs/react/v0.10.0/introduction.mdx index cfc6cea39..617b07c26 100644 --- a/pages/docs/react/v0.10.0/introduction.mdx +++ b/pages/docs/react/v0.10.0/introduction.mdx @@ -18,7 +18,7 @@ All our documented examples can be compiled in our [ReScript Playground](/try) a - Comes with all essential React APIs for building production ready apps (`useState`, `useReducer`, `useEffect`, `useRef`,...) - No component class API (all ReScript & React codebases are built on functional components & hooks) - Strong level of type safetiness and type inference for component props and state values -- [GenType](/docs/gentype/latest/introduction) support for importing / exporting React components in Flow and TypeScript codebases +- [GenType](/docs/manual/latest/gentype-introduction) support for importing / exporting React components in Flow and TypeScript codebases > **This documentation assumes basic knowledge about ReactJS.** > diff --git a/pages/docs/react/v0.11.0/introduction.mdx b/pages/docs/react/v0.11.0/introduction.mdx index 5fab2d8e7..09a225e9b 100644 --- a/pages/docs/react/v0.11.0/introduction.mdx +++ b/pages/docs/react/v0.11.0/introduction.mdx @@ -18,7 +18,7 @@ All our documented examples can be compiled in our [ReScript Playground](/try) a - Comes with all essential React APIs for building production ready apps (`useState`, `useReducer`, `useEffect`, `useRef`,...) - No component class API (all ReScript & React codebases are built on function components & hooks) - Strong level of type safetiness and type inference for component props and state values -- [GenType](/docs/gentype/latest/introduction) support for importing / exporting React components in TypeScript codebases +- [GenType](/docs/manual/latest/gentype-introduction) support for importing / exporting React components in TypeScript codebases > **This documentation assumes basic knowledge about ReactJS.** > diff --git a/scripts/extract-tocs.mjs b/scripts/extract-tocs.mjs index f6d122c54..c83a57bff 100644 --- a/scripts/extract-tocs.mjs +++ b/scripts/extract-tocs.mjs @@ -274,32 +274,6 @@ const createReactToc = (version) => { fs.writeFileSync(TARGET_FILE, JSON.stringify(toc), "utf8"); }; -const createGenTypeToc = () => { - const MD_DIR = path.join(__dirname, "../pages/docs/gentype/latest"); - const SIDEBAR_JSON = path.join( - __dirname, - "../data/sidebar_gentype_latest.json" - ); - const TARGET_FILE = path.join( - __dirname, - "../index_data/gentype_latest_toc.json" - ); - - const sidebarJson = JSON.parse(fs.readFileSync(SIDEBAR_JSON)); - - const FILE_ORDER = Object.values(sidebarJson).reduce((acc, items) => { - return acc.concat(items); - }, []); - - const files = glob.sync(`${MD_DIR}/*.?(js|md?(x))`); - const ordered = orderFiles(files, FILE_ORDER); - - const result = ordered.map((filepath) => processFile(filepath, sidebarJson)); - const toc = createTOC(result); - - fs.writeFileSync(TARGET_FILE, JSON.stringify(toc), "utf8"); -}; - const createCommunityToc = () => { const MD_DIR = path.join(__dirname, "../pages/community"); const SIDEBAR_JSON = path.join(__dirname, "../data/sidebar_community.json"); @@ -344,5 +318,4 @@ createReasonCompilerToc(); createReactToc("latest"); createReactToc("v0.10.0"); createReactToc("v0.11.0"); -createGenTypeToc(); createCommunityToc(); diff --git a/src/DocsOverview.res b/src/DocsOverview.res index b4c212f8a..2e6f47825 100644 --- a/src/DocsOverview.res +++ b/src/DocsOverview.res @@ -36,7 +36,7 @@ let default = (~showVersionSelect=true) => { let ecosystem = [ ("Package Index", "/packages"), ("rescript-react", "/docs/react/latest/introduction"), - ("GenType", "/docs/gentype/latest/introduction"), + ("GenType", "/docs/manual/latest/gentype-introduction"), ("Reanalyze", "https://github.com/reason-association/reanalyze"), ] diff --git a/src/common/App.res b/src/common/App.res index 4f23c8073..df45ba017 100644 --- a/src/common/App.res +++ b/src/common/App.res @@ -136,8 +136,6 @@ let make = (props: props): React.element => { } | {base: ["docs", "reason-compiler"], version: Latest} => content - | {base: ["docs", "gentype"], version: Latest} => - frontmatter}> content // common routes | {base} => switch Belt.List.fromArray(base) { diff --git a/src/common/Constants.res b/src/common/Constants.res index 7548162eb..e319f6695 100644 --- a/src/common/Constants.res +++ b/src/common/Constants.res @@ -20,7 +20,7 @@ let languageManual = version => { let ecosystem = [ ("Package Index", "/packages"), ("rescript-react", "/docs/react/latest/introduction"), - ("GenType", "/docs/gentype/latest/introduction"), + ("GenType", "/docs/manual/latest/gentype-introduction"), ("Reanalyze", "https://github.com/reason-association/reanalyze"), ] diff --git a/src/components/Navigation.res b/src/components/Navigation.res index a1cd1e8a1..495944d4b 100644 --- a/src/components/Navigation.res +++ b/src/components/Navigation.res @@ -168,8 +168,8 @@ module DocsSection = { description: "Reference for all language features", href: `/docs/manual/${version}/introduction`, isActive: url => { - switch url.base { - | ["docs", "manual"] => true + switch url.fullpath { + | ["docs", "manual", _, fragment] => !(fragment->Js.String2.startsWith("gentype")) | _ => false } }, @@ -189,11 +189,11 @@ module DocsSection = { { imgSrc: "/static/ic_gentype@2x.png", title: "GenType", - description: "Seamless TypeScript & Flow integration", - href: "/docs/gentype/latest/introduction", + description: "Seamless TypeScript integration", + href: "/docs/manual/latest/gentype-introduction", isActive: url => { - switch url.base { - | ["docs", "gentype"] => true + switch url.fullpath { + | ["docs", "manual", _, fragment] => fragment->Js.String2.startsWith("gentype") | _ => false } }, diff --git a/src/layouts/GenTypeDocsLayout.res b/src/layouts/GenTypeDocsLayout.res deleted file mode 100644 index 7bf715c9f..000000000 --- a/src/layouts/GenTypeDocsLayout.res +++ /dev/null @@ -1,46 +0,0 @@ -module LatestLayout = DocsLayout.Make({ - // Structure defined by `scripts/extract-tocs.js` - @module("index_data/gentype_latest_toc.json") external tocData: SidebarLayout.Toc.raw = "default" -}) - -@react.component -let make = (~frontmatter=?, ~components=Markdown.default, ~children) => { - let router = Next.Router.useRouter() - let route = router.route - - let url = route->Url.parse - - let version = switch url.version { - | Version(version) => version - | NoVersion => "latest" - | Latest => "latest" - } - - let breadcrumbs = list{ - { - open Url - {name: "Docs", href: "/docs/latest"} - }, - { - open Url - { - name: "GenType", - href: "/docs/gentype/" ++ (version ++ "/introduction"), - } - }, - } - - let title = "GenType" - let version = "v4" - - - children - -} diff --git a/src/layouts/GenTypeDocsLayout.resi b/src/layouts/GenTypeDocsLayout.resi deleted file mode 100644 index 4e3e224be..000000000 --- a/src/layouts/GenTypeDocsLayout.resi +++ /dev/null @@ -1,6 +0,0 @@ -@react.component -let make: ( - ~frontmatter: Js.Json.t=?, - ~components: Mdx.Components.t=?, - ~children: React.element, -) => React.element diff --git a/src/layouts/LandingPageLayout.res b/src/layouts/LandingPageLayout.res index 4cd7acce7..a81015b83 100644 --- a/src/layouts/LandingPageLayout.res +++ b/src/layouts/LandingPageLayout.res @@ -577,7 +577,7 @@ module CuratedResources = { imgSrc: "/static/ic_gentype@2x.png", title: React.string("TypeScript Integration"), descr: "Learn how to integrate ReScript in your existing TypeScript codebases.", - href: "/docs/gentype/latest/introduction", + href: "/docs/manual/latest/gentype-introduction", }, ]