Skip to content

Commit 42bbc76

Browse files
committed
fix(website): make homepage self-contained
1 parent 2c79639 commit 42bbc76

3 files changed

Lines changed: 19 additions & 36 deletions

File tree

website/pages/index.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,20 @@ <h2>Docs</h2>
475475
</ul>
476476

477477
<h2>Runnable Examples</h2>
478-
<!-- @example-explorer -->
478+
<div class="example-teaser">
479+
<div>
480+
<p class="eyebrow">runnable example</p>
481+
<h3>Data-first JSON</h3>
482+
<p>
483+
Start with plain JSON users, posts, and settings, then let @async/db infer the first schema and runtime
484+
state. This is the smallest useful project shape before adding explicit schema.
485+
</p>
486+
</div>
487+
<div class="button-row">
488+
<a class="primary-link" href="../../examples/data-first/README.md">Open example</a>
489+
<a href="https://github.com/async-framework/async-db/tree/main/examples/data-first" rel="noopener">View on GitHub</a>
490+
</div>
491+
</div>
479492

480493
<p class="footer">
481494
Built from <a href="../db.schema.js">website/db.schema.js</a> content collections and published from

website/src/landing.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { readFile } from 'node:fs/promises';
22
import path from 'node:path';
33
import { fileURLToPath } from 'node:url';
4-
import { loadAllExamples, loadTeaserExample } from './examples-loader.js';
5-
import { renderExamplesPage, renderExamplesTeaser, renderLandingWithTeaser } from './render-examples-page.js';
4+
import { loadAllExamples } from './examples-loader.js';
5+
import { renderExamplesPage, renderLandingPage } from './render-examples-page.js';
66

77
const websiteRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
88
const repoRoot = path.resolve(websiteRoot, '..');
@@ -15,7 +15,5 @@ export async function buildExamplesPage() {
1515
export async function buildLandingPageHtml() {
1616
const landingPath = path.join(websiteRoot, 'pages', 'index.html');
1717
const landingHtml = await readFile(landingPath, 'utf8');
18-
const teaserExample = await loadTeaserExample(repoRoot);
19-
const teaserHtml = renderExamplesTeaser(teaserExample);
20-
return renderLandingWithTeaser(landingHtml, teaserHtml);
18+
return renderLandingPage(landingHtml);
2119
}

website/src/render-examples-page.js

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -74,36 +74,8 @@ export function renderExamplesPage(examples) {
7474
});
7575
}
7676

77-
/**
78-
* @param {Awaited<ReturnType<import('./examples-loader.js').loadTeaserExample>>} example
79-
*/
80-
export function renderExamplesTeaser(example) {
81-
return `
82-
<div class="example-teaser">
83-
<div>
84-
<p class="eyebrow">runnable example</p>
85-
<h3>${escapeHtml(example.title)}</h3>
86-
<p>${escapeHtml(example.intro || 'Open a complete example project with the data files, config, and commands together.')}</p>
87-
</div>
88-
<div class="button-row">
89-
<a class="primary-link" href="./docs/examples.html">Browse examples</a>
90-
<a href="${escapeHtml(example.githubUrl)}" rel="noopener">Open on GitHub</a>
91-
</div>
92-
</div>
93-
`;
94-
}
95-
96-
const TEASER_PLACEHOLDER = '<!-- @example-explorer -->';
97-
98-
export function renderLandingWithTeaser(landingHtml, teaserHtml) {
99-
if (!landingHtml.includes(TEASER_PLACEHOLDER)) {
100-
throw new Error(`Landing page is missing the ${TEASER_PLACEHOLDER} placeholder.`);
101-
}
102-
// Function replacements avoid String.replace's special "$" substitution
103-
// patterns, which could corrupt injected example file contents.
104-
const withTeaser = landingHtml.replace(TEASER_PLACEHOLDER, () => teaserHtml);
105-
const withPagesLinks = withTeaser.replace(/href="([^"]+)"/gu, (match, href) => (
77+
export function renderLandingPage(landingHtml) {
78+
return landingHtml.replace(/href="([^"]+)"/gu, (match, href) => (
10679
`href="${escapeHtml(rewriteLandingSourceLink(href))}"`
10780
));
108-
return withPagesLinks;
10981
}

0 commit comments

Comments
 (0)