Skip to content

Remove duplicate title and fix left sidebar position #1057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/ApiDocs.res
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ module SidebarTree = {

let preludeSection =
<div className="flex justify-between text-fire font-medium items-baseline">
{React.string(node.name ++ " Module")}
{switch url {
| Some(url) =>
let onChange = evt => {
Expand Down Expand Up @@ -207,7 +206,7 @@ module SidebarTree = {
) ++ " md:block md:w-48 md:-ml-4 lg:w-1/5 md:h-auto md:relative overflow-y-visible bg-white"}>
<aside
id="sidebar-content"
className="relative top-0 px-4 w-full block md:top-16 md:pt-16 md:sticky border-r border-gray-20 overflow-y-auto pb-24 h-[calc(100vh-4.5rem)]">
className="relative top-0 px-4 w-full block md:top-[7rem] md:pt-10 md:sticky border-r border-gray-20 overflow-y-auto pb-24 h-[calc(100vh-7rem)]">
<div className="flex justify-between">
<div className="w-3/4 md:w-full"> React.null </div>
<button
Expand Down Expand Up @@ -350,7 +349,7 @@ let default = (props: props) => {
| Ok({module_: {items}}) if Array.length(items) > 0 =>
<div className="hidden xl:block lg:w-1/5 md:h-auto md:relative overflow-y-visible bg-white">
<aside
className="relative top-0 pl-4 w-full block md:top-16 md:pt-16 md:sticky border-l border-gray-20 overflow-y-auto pb-24 h-[calc(100vh-4.5rem)]">
className="relative top-0 pl-4 w-full block md:top-[7rem] md:pt-4 md:sticky border-l border-gray-20 overflow-y-auto pb-24 h-[calc(100vh-7rem)]">
<div className="hl-overline block text-gray-80 mt-16 mb-2">
{"Types and values"->React.string}
</div>
Expand Down
1 change: 0 additions & 1 deletion src/layouts/ApiLayout.res
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ let make = (

let preludeSection =
<div className="flex justify-between text-fire font-medium items-baseline">
{React.string(title)}
{switch version {
| Some(version) =>
let onChange = evt => {
Expand Down
3 changes: 1 addition & 2 deletions src/layouts/ApiOverviewLayout.res
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ let makeCategories: string => array<Sidebar.Category.t> = version => [
module Docs = {
@react.component
let make = (~version, ~components=ApiMarkdown.default, ~children) => {
let title = "API"
let categories = makeCategories(version)

<ApiLayout title categories version components> children </ApiLayout>
<ApiLayout categories version components> children </ApiLayout>
}
}
4 changes: 1 addition & 3 deletions src/layouts/CommunityLayout.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ module CommunityLayout = DocsLayout.Make({
let make = (~frontmatter=?, ~components=MarkdownComponents.default, ~children) => {
let breadcrumbs = list{{Url.name: "Community", href: "/community"}}

let title = "Community"

<CommunityLayout
theme=#Reason components metaTitleCategory="ReScript Community" title breadcrumbs ?frontmatter>
theme=#Reason components metaTitleCategory="ReScript Community" breadcrumbs ?frontmatter>
children
</CommunityLayout>
}
25 changes: 7 additions & 18 deletions src/layouts/DocsLayout.res
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ let makeBreadcrumbs = (~basePath: string, route: string): list<Url.breadcrumb> =
@react.component
let make = (
~breadcrumbs: option<list<Url.breadcrumb>>=?,
~title: string,
~metaTitleCategory: option<string>=?, // e.g. Introduction | My Meta Title Category
~metaTitleCategory: string, // e.g. Introduction | My Meta Title Category
~frontmatter=?,
~version: option<string>=?,
~availableVersions: option<array<(string, string)>>=?,
Expand Down Expand Up @@ -86,7 +85,6 @@ let make = (

let preludeSection =
<div className="flex flex-col justify-between text-fire font-medium items-baseline">
{React.string(title)}
{switch version {
| Some(version) =>
switch availableVersions {
Expand All @@ -111,30 +109,23 @@ let make = (
</div>

let sidebar =
<Sidebar
isOpen=isSidebarOpen toggle=toggleSidebar preludeSection title ?activeToc categories route
/>
<Sidebar isOpen=isSidebarOpen toggle=toggleSidebar preludeSection ?activeToc categories route />

let metaTitle = switch metaTitleCategory {
| Some(titleCategory) => titleCategory ++ (" | " ++ "ReScript Documentation")
| None => title
}
let metaTitle = metaTitleCategory ++ (" | " ++ "ReScript Documentation")

let (metaElement, editHref) = switch frontmatter {
| Some(frontmatter) =>
switch DocFrontmatter.decode(frontmatter) {
| Some(fm) =>
let canonical = Null.toOption(fm.canonical)
let description = Null.toOption(fm.description)
let title = switch metaTitleCategory {
| Some(titleCategory) =>
let title = {
// We will prefer an existing metaTitle over just a title
let metaTitle = switch Null.toOption(fm.metaTitle) {
| Some(metaTitle) => metaTitle
| None => fm.title
}
metaTitle ++ (" | " ++ titleCategory)
| None => title
metaTitle ++ (" | " ++ metaTitleCategory)
}
let meta = <Meta title ?description ?canonical version=Url.parse(router.route).version />

Expand Down Expand Up @@ -173,8 +164,7 @@ module Make = (Content: StaticContent) => {
let make = (
// base breadcrumbs without the very last element (the currently shown document)
~breadcrumbs: option<list<Url.breadcrumb>>=?,
~title: string,
~metaTitleCategory: option<string>=?,
~metaTitleCategory: string,
~frontmatter=?,
~version: option<string>=?,
~availableVersions: option<array<(string, string)>>=?,
Expand Down Expand Up @@ -235,8 +225,7 @@ module Make = (Content: StaticContent) => {

make({
?breadcrumbs,
title,
?metaTitleCategory,
metaTitleCategory,
?frontmatter,
?version,
?availableVersions,
Expand Down
6 changes: 2 additions & 4 deletions src/layouts/DocsLayout.resi
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ let makeBreadcrumbs: (~basePath: string, string) => list<Url.breadcrumb>
@react.component
let make: (
~breadcrumbs: list<Url.breadcrumb>=?,
~title: string,
~metaTitleCategory: string=?, // e.g. Introduction | My Meta Title Category
~metaTitleCategory: string, // e.g. Introduction | My Meta Title Category
~frontmatter: JSON.t=?,
~version: string=?,
~availableVersions: array<(string, string)>=?,
Expand All @@ -27,8 +26,7 @@ module Make: (Content: StaticContent) =>
@react.component
let make: (
~breadcrumbs: list<Url.breadcrumb>=?,
~title: string,
~metaTitleCategory: string=?,
~metaTitleCategory: string,
~frontmatter: JSON.t=?,
~version: string=?,
~availableVersions: array<(string, string)>=?,
Expand Down
12 changes: 1 addition & 11 deletions src/layouts/ManualDocsLayout.res
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module V1200Layout = DocsLayout.Make({
module V1200 = {
@react.component
let make = (~frontmatter=?, ~components=MarkdownComponents.default, ~children) => {
let title = "Language Manual"
let router = Next.Router.useRouter()
let url = router.route->Url.parse
let version = url->Url.getVersionString
Expand Down Expand Up @@ -59,7 +58,6 @@ module V1200 = {
theme=#Reason
components
version
title
metaTitleCategory="ReScript Language Manual"
availableVersions=Constants.allManualVersions
nextVersion=?Constants.nextVersion
Expand All @@ -74,7 +72,6 @@ module V1200 = {
module V1100 = {
@react.component
let make = (~frontmatter=?, ~components=MarkdownComponents.default, ~children) => {
let title = "Language Manual"
let router = Next.Router.useRouter()
let version = router.route->Url.parse->Url.getVersionString

Expand All @@ -87,7 +84,6 @@ module V1100 = {
theme=#Reason
components
version
title
metaTitleCategory="ReScript Language Manual"
availableVersions=Constants.allManualVersions
nextVersion=?Constants.nextVersion
Expand Down Expand Up @@ -122,13 +118,12 @@ module V1000 = {
},
}

let title = "Language Manual"
// let title = "Language Manual"

<V1000Layout
theme=#Reason
components
version
title
metaTitleCategory="ReScript Language Manual"
availableVersions=Constants.allManualVersions
nextVersion=?Constants.nextVersion
Expand Down Expand Up @@ -167,13 +162,10 @@ module V900 = {
},
}

let title = "Language Manual"

<V900Layout
theme=#Reason
components
version
title
metaTitleCategory="ReScript Language Manual"
availableVersions=Constants.allManualVersions
nextVersion=?Constants.nextVersion
Expand Down Expand Up @@ -208,7 +200,6 @@ module V800 = {
},
}

let title = "Language Manual"
let version = "v8.0.0"

let warnBanner = {
Expand Down Expand Up @@ -249,7 +240,6 @@ module V800 = {
theme=#Reason
components
version
title
metaTitleCategory="ReScript Language Manual"
availableVersions=Constants.allManualVersions
nextVersion=?Constants.nextVersion
Expand Down
8 changes: 0 additions & 8 deletions src/layouts/ReactDocsLayout.res
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ module Latest = {
{name: "rescript-react", href: "/docs/react/" ++ (version ++ "/introduction")},
}

let title = "rescript-react"
let version = "latest"

<LatestLayout
Expand All @@ -45,7 +44,6 @@ module Latest = {
metaTitleCategory="React"
availableVersions=Constants.allReactVersions
version
title
breadcrumbs
?frontmatter>
children
Expand All @@ -70,15 +68,12 @@ module V0110 = {
{name: "rescript-react", href: "/docs/react/" ++ (version ++ "/introduction")},
}

let title = "rescript-react"

<V0110Layout
theme=#Reason
components
metaTitleCategory="React"
availableVersions=Constants.allReactVersions
version
title
breadcrumbs
?frontmatter>
children
Expand All @@ -103,15 +98,12 @@ module V0100 = {
{name: "rescript-react", href: "/docs/react/" ++ (version ++ "/introduction")},
}

let title = "rescript-react"

<V0100Layout
theme=#Reason
components
metaTitleCategory="React"
availableVersions=Constants.allReactVersions
version
title
breadcrumbs
?frontmatter>
children
Expand Down
5 changes: 2 additions & 3 deletions src/layouts/SidebarLayout.res
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,10 @@ module Sidebar = {
id="sidebar"
className={(
isOpen ? "fixed w-full left-0 h-full z-20 min-w-320" : "hidden "
) ++ " overflow-x-hidden md:block md:w-48 md:-ml-4 lg:w-1/5 md:h-auto md:relative overflow-y-visible bg-white mt-28 md:mt-0"}>
) ++ " md:block md:w-48 md:-ml-4 lg:w-1/5 md:h-auto md:relative overflow-y-visible bg-white mt-28 md:mt-0"}>
<aside
id="sidebar-content"
className="relative top-0 px-4 w-full block md:top-16 md:pt-4 md:sticky border-r border-gray-20 overflow-y-auto pb-24"
style={ReactDOMStyle.make(~height="calc(100vh - 4.5rem", ())}>
className="relative top-0 px-4 w-full block md:top-[7rem] md:pt-10 md:sticky border-r border-gray-20 overflow-y-auto pb-24 h-[calc(100vh-7rem)]">
<button
onClick={evt => {
ReactEvent.Mouse.preventDefault(evt)
Expand Down