diff --git a/pages/[lang]/community/aroundweb.res b/pages/[lang]/community/aroundweb.res index 34cd5f54..718e0ca7 100644 --- a/pages/[lang]/community/aroundweb.res +++ b/pages/[lang]/community/aroundweb.res @@ -63,7 +63,7 @@ module T = { } @react.component - let make = (~content) => + let make = (~content, ~lang) =>
@@ -110,7 +110,7 @@ module T = { t={ CallToAction.title: content.title, body: content.description, - buttonLink: Route(InternalUrls.communityEvents), + buttonLink: Route(#communityEvents, lang), buttonText: content.callToAction, } /> @@ -149,7 +149,7 @@ module T = { module Params = Pages.Params.Lang @react.component - let make = (~content, ~params as {Params.lang: _}) => <> + let make = (~content, ~params as {Params.lang: lang}) => <> - +
diff --git a/pages/[lang]/community/blog.res b/pages/[lang]/community/blog.res index 2013f0a3..213e3868 100644 --- a/pages/[lang]/community/blog.res +++ b/pages/[lang]/community/blog.res @@ -33,31 +33,41 @@ module T = { goToNewsArchive: string, } - let toHighlightsInQuadrantsContent = t => { - HighlightsInQuadrants.title: t.otherNewsStories, + let toHighlightsInQuadrantsContent = ( + { + otherNewsStories, + communityCategory, + releasesCategory, + industryCategory, + eventsCategory, + goToNewsArchive, + }: t, + lang, + ) => { + HighlightsInQuadrants.title: otherNewsStories, topLeftCategory: NewsCategory.toHighlightsCategory( - t.communityCategory, - InternalUrls.communityNewsarchive, // TODO: should we use a query parameter for the category? + communityCategory, + #communityNewsarchive->Route.toString(lang), // TODO: should we use a query parameter for the category? HighlightsInQuadrants.CategoryHeaderIcon.Meet, ), topRightCategory: NewsCategory.toHighlightsCategory( - t.releasesCategory, - InternalUrls.communityNewsarchive, + releasesCategory, + #communityNewsarchive->Route.toString(lang), HighlightsInQuadrants.CategoryHeaderIcon.Package, ), bottomLeftCategory: NewsCategory.toHighlightsCategory( - t.industryCategory, - InternalUrls.communityNewsarchive, + industryCategory, + #communityNewsarchive->Route.toString(lang), HighlightsInQuadrants.CategoryHeaderIcon.Profit, ), bottomRightCategory: NewsCategory.toHighlightsCategory( - t.eventsCategory, - InternalUrls.communityNewsarchive, + eventsCategory, + #communityNewsarchive->Route.toString(lang), HighlightsInQuadrants.CategoryHeaderIcon.Calendar, ), goToArchive: { - label: t.goToNewsArchive, - link: InternalUrls.communityNewsarchive, + label: goToNewsArchive, + link: #communityNewsarchive->Route.toString(lang), }, } } @@ -266,7 +276,7 @@ module T = { module Params = Pages.Params.Lang @react.component - let make = (~content, ~params as {Params.lang: _}) => <> + let make = (~content, ~params as {Params.lang: lang}) => <> diff --git a/pages/[lang]/community/events.res b/pages/[lang]/community/events.res index 393e57a6..692df76d 100644 --- a/pages/[lang]/community/events.res +++ b/pages/[lang]/community/events.res @@ -10,12 +10,12 @@ module T = { } include Jsonable.Unsafe - let dedicated_page = (event: Ood.Event.t) => { + let dedicatedPage = (event: Ood.Event.t) => { // OCaml workshop pages switch List.find_opt(String.equal("ocaml-workshop"), event.tags) { | Some(_) => switch Js.Date.fromString(event.date)->Js.Date.getFullYear { - | 2020. => Some(InternalUrls.communityEventOud2020) + | 2020. => Some(#communityEventOud2020) | _ => None } | None => None @@ -25,7 +25,7 @@ module T = { module Params = Pages.Params.Lang @react.component - let make = (~content, ~params as {Params.lang: _}) => <> + let make = (~content, ~params as {Params.lang: lang}) => <> @@ -36,9 +36,9 @@ module T = { headers: ["Date", "Event Name", "Location", "Description"], data: Array.map((event: Ood.Event.t) => [

{s(event.date |> Js.Date.fromString |> Js.Date.toDateString)}

, - switch dedicated_page(event) { + switch dedicatedPage(event) { | Some(page) => - + Route.toString(lang)}> {s(event.title)} | None =>

{s(event.title)}

diff --git a/pages/[lang]/index.res b/pages/[lang]/index.res index fff51d92..52713f82 100644 --- a/pages/[lang]/index.res +++ b/pages/[lang]/index.res @@ -52,7 +52,7 @@ module T = { } @react.component - let make = (~content) => + let make = (~content, ~lang) =>
@@ -61,13 +61,13 @@ module T = {
@@ -242,7 +243,7 @@ module T = { module Params = Pages.Params.Lang @react.component - let make = (~content, ~params as {Params.lang: _}) => <> + let make = (~content, ~params as {Params.lang: lang}) => <> - + - + } diff --git a/src/CallToAction.res b/src/CallToAction.res index 659e82e1..1e49d730 100644 --- a/src/CallToAction.res +++ b/src/CallToAction.res @@ -1,14 +1,12 @@ -module Link = Next.Link - let s = React.string // TODO: move this into a future Link component once the Url and Link types have been thought out module LinkUrl = { - type t = Route(string) | External(string) + type t = Route(Route.t, Lang.t) | External(string) let render = (~t, ~buttonText, ~styling) => switch t { - | Route(url) => {s(buttonText)} + | Route(_to, lang) => {s(buttonText)} | External(url) => {s(buttonText)} } } diff --git a/src/CallToAction.resi b/src/CallToAction.resi index 749ac431..a42bab98 100644 --- a/src/CallToAction.resi +++ b/src/CallToAction.resi @@ -1,5 +1,5 @@ module LinkUrl: { - type t = Route(string) | External(string) + type t = Route(Route.t, Lang.t) | External(string) } type t = { diff --git a/src/GlobalData.res b/src/GlobalData.res index 9b2e4508..7c5a0ff2 100644 --- a/src/GlobalData.res +++ b/src/GlobalData.res @@ -29,87 +29,90 @@ type navContent = { } let navContentEn = { - principlesSection: { - header: `Principles`, - whatIsOcaml: { - label: `Why OCaml`, - url: InternalUrls.principlesWhatisocaml, - icon: Icons.camel, - text: "Find out about OCaml's history and how it became what it is today.", - }, - industrialUsers: { - label: `Industrial Users`, - url: InternalUrls.principlesIndustrialUsers, - icon: Icons.industry, - text: "Discover the organisations that use OCaml to accomplish their goals.", - }, - academicExcellence: { - label: `Academic Excellence`, - url: InternalUrls.principlesAcademic, - icon: Icons.academic, - text: "Learn about the academics that research programming language technology.", - }, - successStories: { - label: `Success Stories`, - url: InternalUrls.principlesSuccesses, - icon: Icons.success, - text: "Read about the things that have been achieved using OCaml.", - }, - }, - resourcesSection: { - header: `Resources`, - language: { - label: `Language`, - url: InternalUrls.resourcesLanguage, - icon: Icons.language, - text: "Read through the OCaml tutorial, official manual and books.", - }, - packages: { - label: `Packages`, - url: "http://ci5.ocamllabs.io:8082/" /* TODO - point to correct page once it's created */, - icon: Icons.packages, - text: "Browse the third-party packages published in the OCaml ecosystem.", - }, - applications: { - label: `Applications`, - url: InternalUrls.resourcesApplications, - icon: Icons.applications, - text: "Learn techniques for building tools and applications in OCaml.", - }, - bestPractices: { - label: `Best Practices`, - url: InternalUrls.resourcesBestpractices, - icon: Icons.bestPractices, - text: "Adopt the best known methods for development from the OCaml community.", - }, - }, - communitySection: { - header: `Community`, - opportunities: { - label: `Opportunities`, - url: InternalUrls.communityOpportunities, - icon: Icons.opportunities, - text: "Explore vacancies in projects and companies and see where you could fit in.", - }, - news: { - label: `News`, - url: InternalUrls.communityNews, - icon: Icons.news, - text: "Catch up on the latest news from the OCaml sphere!", + let url = Route.toString(_, #en) + { + principlesSection: { + header: `Principles`, + whatIsOcaml: { + label: `Why OCaml`, + url: url(#principlesWhatisocaml), + icon: Icons.camel, + text: "Find out about OCaml's history and how it became what it is today.", + }, + industrialUsers: { + label: `Industrial Users`, + url: url(#principlesIndustrialUsers), + icon: Icons.industry, + text: "Discover the organisations that use OCaml to accomplish their goals.", + }, + academicExcellence: { + label: `Academic Excellence`, + url: url(#principlesAcademic), + icon: Icons.academic, + text: "Learn about the academics that research programming language technology.", + }, + successStories: { + label: `Success Stories`, + url: url(#principlesSuccesses), + icon: Icons.success, + text: "Read about the things that have been achieved using OCaml.", + }, }, - aroundTheWeb: { - label: `Around the Web`, - url: InternalUrls.communityAroundweb, - icon: Icons.web, - text: "A bit of everything, this page encapsulates OCaml's presence online, blogposts, videos, and mailing lists all live here.", + resourcesSection: { + header: `Resources`, + language: { + label: `Language`, + url: url(#resourcesLanguage), + icon: Icons.language, + text: "Read through the OCaml tutorial, official manual and books.", + }, + packages: { + label: `Packages`, + url: "http://ci5.ocamllabs.io:8082/" /* TODO - point to correct page once it's created */, + icon: Icons.packages, + text: "Browse the third-party packages published in the OCaml ecosystem.", + }, + applications: { + label: `Applications`, + url: url(#resourcesApplications), + icon: Icons.applications, + text: "Learn techniques for building tools and applications in OCaml.", + }, + bestPractices: { + label: `Best Practices`, + url: url(#resourcesBestpractices), + icon: Icons.bestPractices, + text: "Adopt the best known methods for development from the OCaml community.", + }, }, - archive: { - label: `Archive`, - url: InternalUrls.resourcesArchive, - icon: Icons.archive, - text: "Can't find what you're looking for? Try searching the Archive.", + communitySection: { + header: `Community`, + opportunities: { + label: `Opportunities`, + url: url(#communityOpportunities), + icon: Icons.opportunities, + text: "Explore vacancies in projects and companies and see where you could fit in.", + }, + news: { + label: `News`, + url: url(#communityNews), + icon: Icons.news, + text: "Catch up on the latest news from the OCaml sphere!", + }, + aroundTheWeb: { + label: `Around the Web`, + url: url(#communityAroundweb), + icon: Icons.web, + text: "A bit of everything, this page encapsulates OCaml's presence online, blogposts, videos, and mailing lists all live here.", + }, + archive: { + label: `Archive`, + url: url(#resourcesArchive), + icon: Icons.archive, + text: "Can't find what you're looking for? Try searching the Archive.", + }, }, - }, + } } let headerContentEn: HeaderNavigation.content = { @@ -145,61 +148,74 @@ let headerContentEn: HeaderNavigation.content = { } let footerContentEn: Footer.t = { - footer: `Footer`, - logoContent: { - ocamlSummary: `Innovation. Community. Security.`, - }, - mainLinksContent: { - principlesSection: { - header: navContentEn.principlesSection.header, - entries: [ - navContentEn.principlesSection.whatIsOcaml, - navContentEn.principlesSection.industrialUsers, - navContentEn.principlesSection.academicExcellence, - navContentEn.principlesSection.successStories, - ], + let url = Route.toString(_, #en) + { + footer: `Footer`, + logoContent: { + ocamlSummary: `Innovation. Community. Security.`, }, - resourcesSection: { - header: navContentEn.resourcesSection.header, - entries: [ - navContentEn.resourcesSection.language, - navContentEn.resourcesSection.packages, - navContentEn.resourcesSection.applications, - navContentEn.resourcesSection.bestPractices, - ], - }, - communitySection: { - header: navContentEn.communitySection.header, - entries: [ - navContentEn.communitySection.opportunities, - navContentEn.communitySection.news, - navContentEn.communitySection.aroundTheWeb, - navContentEn.communitySection.archive, - ], + mainLinksContent: { + principlesSection: { + header: navContentEn.principlesSection.header, + entries: [ + navContentEn.principlesSection.whatIsOcaml, + navContentEn.principlesSection.industrialUsers, + navContentEn.principlesSection.academicExcellence, + navContentEn.principlesSection.successStories, + ], + }, + resourcesSection: { + header: navContentEn.resourcesSection.header, + entries: [ + navContentEn.resourcesSection.language, + navContentEn.resourcesSection.packages, + navContentEn.resourcesSection.applications, + navContentEn.resourcesSection.bestPractices, + ], + }, + communitySection: { + header: navContentEn.communitySection.header, + entries: [ + navContentEn.communitySection.opportunities, + navContentEn.communitySection.news, + navContentEn.communitySection.aroundTheWeb, + navContentEn.communitySection.archive, + ], + }, + legalSection: { + header: `Legal`, + entries: [ + { + label: `Privacy`, + url: url(#legalPrivacy), + icon: Icons.industry, + text: "", + }, + { + label: `Terms`, + url: url(#legalTerms), + icon: Icons.industry, + text: "", + }, + { + label: `Carbon Footprint`, + url: url(#legalCarbonfootprint), + icon: Icons.industry, + text: "", + }, + ], + }, }, - legalSection: { - header: `Legal`, - entries: [ - {label: `Privacy`, url: InternalUrls.legalPrivacy, icon: Icons.industry, text: ""}, - {label: `Terms`, url: InternalUrls.legalTerms, icon: Icons.industry, text: ""}, - { - label: `Carbon Footprint`, - url: InternalUrls.legalCarbonfootprint, - icon: Icons.industry, - text: "", - }, - ], + sponsorContent: { + thankSponsorPrefix: `Thank you to our`, + hostingProviders: { + label: `Hosting Providers`, + url: url(#legalCarbonfootprint) ++ `#hostingproviders`, + icon: Icons.industry, + text: "", + }, }, - }, - sponsorContent: { - thankSponsorPrefix: `Thank you to our`, - hostingProviders: { - label: `Hosting Providers`, - url: `${InternalUrls.legalCarbonfootprint}#hostingproviders`, - icon: Icons.industry, - text: "", - }, - }, + } } let milestonesContentEn: Milestones.t = { diff --git a/src/InternalUrls.res b/src/InternalUrls.res deleted file mode 100644 index 00186e0e..00000000 --- a/src/InternalUrls.res +++ /dev/null @@ -1,29 +0,0 @@ -let make = path => "/en" ++ path -let index = make("/") -let history = make("/history") -let communityAroundweb = make("/community/aroundweb") -let communityEvents = make("/community/events") -let communityEventOud2020 = make("/community/event/oud2020") -let communityMediaarchive = make("/community/mediaarchive") -let communityNews = make("/community/blog") -let communityNewsarchive = make("/community/newsarchive") -let communityOpportunities = make("/community/opportunities") -let principlesSuccesses = make("/principles/successes") -let principlesIndustrialUsers = make("/principles/users") -let principlesAcademic = make("/principles/academic") -let principlesWhatisocaml = make("/principles/whatisocaml") -let legalCarbonfootprint = make("/legal/carbonfootprint") -let legalPrivacy = make("/legal/privacy") -let legalTerms = make("/legal/terms") -let resourcesBasics = make("/resources/basics") -let resourcesInstallocaml = make("/resources/installocaml") -let resourcesApplications = make("/resources/applications") -let resourcesArchive = make("/resources/archive") -let resourcesBestpractices = make("/resources/bestpractices") -let resourcesDevelopinginocaml = make("/resources/developinginocaml") -let resourcesLanguage = make("/resources/language") -let resourcesPapers = make("/resources/papers") -let resourcesPapersarchive = make("/resources/papersarchive") -let resourcesPlatform = make("/resources/platform") -let resourcesReleases = make("/resources/releases") -let resourcesUsingocaml = make("/resources/usingocaml") diff --git a/src/Route.res b/src/Route.res new file mode 100644 index 00000000..244433fc --- /dev/null +++ b/src/Route.res @@ -0,0 +1,73 @@ +open! Import + +type t = [ + | #index + | #history + | #communityAroundweb + | #communityEvents + | #communityEventOud2020 + | #communityMediaarchive + | #communityNews + | #communityNewsarchive + | #communityOpportunities + | #principlesSuccesses + | #principlesIndustrialUsers + | #principlesAcademic + | #principlesWhatisocaml + | #legalCarbonfootprint + | #legalPrivacy + | #legalTerms + | #resourcesBasics + | #resourcesInstallocaml + | #resourcesApplications + | #resourcesArchive + | #resourcesBestpractices + | #resourcesDevelopinginocaml + | #resourcesLanguage + | #resourcesPapers + | #resourcesPapersarchive + | #resourcesPlatform + | #resourcesReleases + | #resourcesUsingocaml +] + +let toString = (t: t, lang) => { + let lang = Lang.toString(lang) + let path = switch t { + | #index => "" + | #history => "history" + | #communityAroundweb => "community/aroundweb" + | #communityEvents => "community/events" + | #communityEventOud2020 => "community/event/oud2020" + | #communityMediaarchive => "community/mediaarchive" + | #communityNews => "community/blog" + | #communityNewsarchive => "community/newsarchive" + | #communityOpportunities => "community/opportunities" + | #principlesSuccesses => "principles/successes" + | #principlesIndustrialUsers => "principles/users" + | #principlesAcademic => "principles/academic" + | #principlesWhatisocaml => "principles/whatisocaml" + | #legalCarbonfootprint => "legal/carbonfootprint" + | #legalPrivacy => "legal/privacy" + | #legalTerms => "legal/terms" + | #resourcesBasics => "resources/basics" + | #resourcesInstallocaml => "resources/installocaml" + | #resourcesApplications => "resources/applications" + | #resourcesArchive => "resources/archive" + | #resourcesBestpractices => "resources/bestpractices" + | #resourcesDevelopinginocaml => "resources/developinginocaml" + | #resourcesLanguage => "resources/language" + | #resourcesPapers => "resources/papers" + | #resourcesPapersarchive => "resources/papersarchive" + | #resourcesPlatform => "resources/platform" + | #resourcesReleases => "resources/releases" + | #resourcesUsingocaml => "resources/usingocaml" + } + "/" ++ lang ++ "/" ++ path +} + +@react.component +let make = (~_to, ~lang, ~children) => { + let href = _to->toString(lang) + children +} diff --git a/src/Route.resi b/src/Route.resi new file mode 100644 index 00000000..2d15b19b --- /dev/null +++ b/src/Route.resi @@ -0,0 +1,37 @@ +open! Import + +type t = [ + | #index + | #history + | #communityAroundweb + | #communityEvents + | #communityEventOud2020 + | #communityMediaarchive + | #communityNews + | #communityNewsarchive + | #communityOpportunities + | #principlesSuccesses + | #principlesIndustrialUsers + | #principlesAcademic + | #principlesWhatisocaml + | #legalCarbonfootprint + | #legalPrivacy + | #legalTerms + | #resourcesBasics + | #resourcesInstallocaml + | #resourcesApplications + | #resourcesArchive + | #resourcesBestpractices + | #resourcesDevelopinginocaml + | #resourcesLanguage + | #resourcesPapers + | #resourcesPapersarchive + | #resourcesPlatform + | #resourcesReleases + | #resourcesUsingocaml +] + +let toString: (t, Lang.t) => string + +@react.component +let make: (~_to: t, ~lang: Lang.t, ~children: React.element) => React.element