Skip to content

Commit 484054c

Browse files
committed
fixup some comments and types
1 parent 76ef14a commit 484054c

File tree

6 files changed

+12
-15
lines changed

6 files changed

+12
-15
lines changed

src/generators/web/client/components/SearchBox/index.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ const MDXSearchBox = () => {
4343
Search documentation
4444
</OramaSearchButton>
4545
<OramaSearchBox
46-
disabled={!client || isLoading}
4746
disableChat={true}
4847
linksTarget="_self"
4948
clientInstance={client}

src/generators/web/client/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createStaticData } from '../utils/staticData.mjs';
1+
import { createStaticData } from '../server/data.mjs';
22

33
declare global {
44
const __STATIC_DATA__: ReturnType<typeof createStaticData>;

src/generators/web/constants.mjs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ export const POLYFILL_PATH = fileURLToPath(
88
new URL('./server/polyfill.mjs', import.meta.url)
99
);
1010

11-
export const TEMPLATE_PLACEHOLDERS = {
12-
TITLE: '__TITLE__',
13-
DEHYDRATED: '__DEHYDRATED__',
14-
JAVASCRIPT: '__JAVASCRIPT__',
15-
};
16-
1711
// Imports are relative to ESBUILD_RESOLVE_DIR
1812
export const JSX_IMPORTS = {
1913
NavBar: {

src/generators/web/index.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,24 @@ async function processEntry(
5959

6060
// Generate and execute server-side code for SSR
6161
const serverCode = buildServerProgram(program);
62-
const serverRenderedHTML = await executeServerCode(serverCode, require);
62+
const dehydrated = await executeServerCode(serverCode, require);
6363

6464
// Generate and bundle client-side code
6565
const clientCode = buildClientProgram(program);
6666
const clientBundle = await bundleCode(clientCode);
6767

6868
// Render the final HTML using the template
6969
const finalHTML = await minify(
70+
// TODO(@avivkeller): Don't depend on mustache
7071
Mustache.render(template, {
7172
title: entry.data.heading.data.name,
72-
dehydrated: serverRenderedHTML,
73+
dehydrated: dehydrated,
7374
javascript: clientBundle.js,
7475
}),
7576
TERSER_MINIFY_OPTIONS
7677
);
7778

78-
// Write HTML file immediately if output directory is specified
79+
// Write HTML file if output directory is specified
7980
if (output) {
8081
await writeFile(join(output, `${entry.data.api}.html`), finalHTML, 'utf-8');
8182
}

src/generators/web/server/data.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { shiki } from '@node-core/rehype-shiki';
22

33
/**
4-
* This creates the static data for the client. For example,
5-
* the map of language display names, without loading Shiki,
6-
* a very large module, on the client.
4+
* This creates static data that the server can pass to the client,
5+
* since there are cases (for example, Shiki's display name map) where
6+
* we want to load a large set of data on the server, and only pass
7+
* a small subset of information to the client.
78
*/
89
export const createStaticData = () => {
910
const shikiDisplayNameMap = [

src/generators/web/utils/bundle.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const uiComponentsResolver = {
4848
* Bundles JavaScript code and returns JS/CSS content
4949
* @param {string} code - Source code to bundle
5050
* @param {import('esbuild').BuildOptions} [options={}]
51-
* @returns {Promise<{js: string, css: string}>}
51+
* @returns {Promise<{js: string, css?: string}>}
5252
*/
5353
export default async (code, options = {}) => {
5454
const result = await esbuild.build({
@@ -77,6 +77,8 @@ export default async (code, options = {}) => {
7777
],
7878
...options,
7979
alias: {
80+
// Preact is much smaller than react, so we
81+
// use it instead
8082
react: 'preact/compat',
8183
'react-dom': 'preact/compat',
8284
...options.alias,

0 commit comments

Comments
 (0)