From 241dc9c99bed4dddbc748aad54cee5bf7d77ab92 Mon Sep 17 00:00:00 2001 From: polwex Date: Sun, 15 Jun 2025 02:29:59 +0700 Subject: lfg --- bs5/server/pages/Index.re | 216 +++++++++++++++++++++++++++++++++++++++++++--- bs5/server/pages/dune | 2 + 2 files changed, 206 insertions(+), 12 deletions(-) (limited to 'bs5/server/pages') diff --git a/bs5/server/pages/Index.re b/bs5/server/pages/Index.re index d5af822..685069a 100644 --- a/bs5/server/pages/Index.re +++ b/bs5/server/pages/Index.re @@ -1,16 +1,208 @@ +open Rsc; +module Section = { + [@react.component] + let make = (~title, ~children, ~description=?) => { + +

+ {React.string(title)} +

+ {switch (description) { + | Some(description) => + description + | None => React.null + }} +
+ children + ; + }; +}; + +module ExpandedContent = { + [@react.component] + let make = (~id, ~content: string, ~updatedAt: float, ~title: string) => { + let lastUpdatedAt = + if (Date.is_today(updatedAt)) { + Date.format_time(updatedAt); + } else { + Date.format_date(updatedAt); + }; + + let summary = + content |> Markdown.extract_text |> Markdown.summarize(~words=20); + + + {switch (String.trim(summary)) { + | "" => {React.string("(No content)")} + | s => s + }} + +
+ }> +
+ title + lastUpdatedAt +
+ ; + }; +}; + module Page = { [@react.async.component] let make = () => { - // let promiseIn2 = - // Lwt.bind(Lwt_unix.sleep(2.0), _ => - // Lwt.return("Solusionao in 2 seconds!") - // ); - // let promiseIn4 = - // Lwt.bind(Lwt_unix.sleep(4.0), _ => - // Lwt.return("Solusionao in 4 seconds!") - // ); + let promiseIn2 = + Lwt.bind(Lwt_unix.sleep(2.0), _ => + Lwt.return("Solusionao in 2 seconds!") + ); + let promiseIn4 = + Lwt.bind(Lwt_unix.sleep(4.0), _ => + Lwt.return("Solusionao in 4 seconds!") + ); + Lwt.return( -
{React.string("Well hi")}
, + + +

+ {React.string( + "Server side rendering server components and client components", + )} +

+ + "React server components. Lazy loading of client components. Client props encodings, such as promises, React elements, and primitive types." + +
+
+
+ +
+
+
+ {React.string("H E A D E R")} )} + string_list=["Item 1", "Item 2"] + promise=promiseIn2> +
+ {React.string( + "This footer is a React.element as a server component into client prop, yay!", + )} +
+
+
+
+
+ {React.string("H E A D E R")} )} + string_list=["Item 1", "Item 2"] + promise=promiseIn2> +
+ {React.string( + "This footer is a React.element as a server component into client prop, yay!", + )} +
+
+
+
+
+ +
+
+
+ +
+
+

+ {React.string("Server functions")} +

+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
, ); }; }; @@ -25,15 +217,15 @@ module App = {
- // -
+ + ; }; }; let handler = request => - Rsc.DreamRSC.create_from_request( + DreamRSC.create_from_request( ~bootstrap_modules=["/static/demo/SinglePageRSC.re.js"], , request, diff --git a/bs5/server/pages/dune b/bs5/server/pages/dune index bc63199..47c4f2b 100644 --- a/bs5/server/pages/dune +++ b/bs5/server/pages/dune @@ -2,6 +2,8 @@ (name pages) (libraries rsc + shared + ; dream lwt.unix server-reason-react.belt -- cgit v1.2.3