Skip to content

Commit

Permalink
Adds initial documentation site infrastructure.
Browse files Browse the repository at this point in the history
Refs #16.

This just sets up a new `@rules_prerender` site which says "Hello, World!".
  • Loading branch information
dgp1130 committed Jul 23, 2023
1 parent 1029031 commit 1ba1bbc
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
)
14 changes: 14 additions & 0 deletions docs/components/layout/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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"],
)
14 changes: 14 additions & 0 deletions docs/components/layout/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { VNode } from 'preact';

/** TODO */
export function Layout({ title, children }: { title: string, children: VNode }): VNode {
return <html lang="en">
<head>
<meta charSet="utf8" />
<title>@rules_prerender - {title}</title>
</head>
<body>
<main>{children}</main>
</body>
</html>;
}
10 changes: 10 additions & 0 deletions docs/site.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Layout } from './components/layout/layout.js';
import { PrerenderResource, renderToHtml } from '@rules_prerender/preact';

export default function*(): Generator<PrerenderResource, void, void> {
yield PrerenderResource.fromHtml('/index.html', renderToHtml(
<Layout title="Documentation Home">
<div>Hello World!</div>
</Layout>
));
}

0 comments on commit 1ba1bbc

Please sign in to comment.