diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel new file mode 100644 index 00000000..248137c3 --- /dev/null +++ b/docs/BUILD.bazel @@ -0,0 +1,23 @@ +load("//:index.bzl", "prerender_pages", "web_resources_devserver") +load("//tools/typescript:defs.bzl", "ts_project") + +prerender_pages( + name = "site", + entry_point = "./site.js", + prerender = ":prerender", + bundle_js = False, # Optimization: No runtime JavaScript yet. +) + +ts_project( + name = "prerender", + srcs = ["site.tsx"], + deps = [ + "//docs/components/layout:layout_prerender", + "//:node_modules/@rules_prerender/preact", + ], +) + +web_resources_devserver( + name = "devserver", + resources = ":site", +) diff --git a/docs/components/layout/BUILD.bazel b/docs/components/layout/BUILD.bazel new file mode 100644 index 00000000..a565a372 --- /dev/null +++ b/docs/components/layout/BUILD.bazel @@ -0,0 +1,14 @@ +load("//:index.bzl", "prerender_component") +load("//tools/typescript:defs.bzl", "ts_project") + +prerender_component( + name = "layout", + prerender = ":prerender", + visibility = ["//docs:__subpackages__"], +) + +ts_project( + name = "prerender", + srcs = ["layout.tsx"], + deps = ["//:node_modules/preact"], +) diff --git a/docs/components/layout/layout.tsx b/docs/components/layout/layout.tsx new file mode 100644 index 00000000..3aa60a99 --- /dev/null +++ b/docs/components/layout/layout.tsx @@ -0,0 +1,14 @@ +import { VNode } from 'preact'; + +/** TODO */ +export function Layout({ title, children }: { title: string, children: VNode }): VNode { + return + + + @rules_prerender - {title} + + +
{children}
+ + ; +} diff --git a/docs/site.tsx b/docs/site.tsx new file mode 100644 index 00000000..4925e6cb --- /dev/null +++ b/docs/site.tsx @@ -0,0 +1,10 @@ +import { Layout } from './components/layout/layout.js'; +import { PrerenderResource, renderToHtml } from '@rules_prerender/preact'; + +export default function*(): Generator { + yield PrerenderResource.fromHtml('/index.html', renderToHtml( + +
Hello World!
+
+ )); +}