Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules/
build/
dist/
dist-server/
coverage/
.DS_Store
*.log
Expand Down
6 changes: 5 additions & 1 deletion nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ server {
index index.html;

location / {
try_files $uri $uri/ /index.html;
try_files $uri/index.html $uri =404;
}

location = /full-llms.txt {
return 308 /llms-full.txt$is_args$args;
}

location ~* \.(?:css|js|png|jpg|jpeg|gif|ico|svg|webp|woff2?)$ {
Expand Down
16 changes: 13 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite --port=3000 --host=0.0.0.0",
"build": "vite build",
"build": "vite build && vite build --ssr src/entry-server.tsx --outDir dist-server && node scripts/prerender.mjs",
"docker:build": "docker compose build tigrcorn-com",
"check": "npm run lint",
"preview": "vite preview",
Expand All @@ -15,6 +15,7 @@
},
"dependencies": {
"@google/genai": "^2.4.0",
"@mdwrk/structured-data": "0.3.0",
"@tailwindcss/vite": "^4.1.14",
"@types/prismjs": "^1.26.6",
"@vitejs/plugin-react": "^5.0.4",
Expand Down
Binary file added public/assets/discovery-card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions scripts/prerender.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { mkdir, readFile, writeFile } from "node:fs/promises";
import { dirname } from "node:path";
import { routes, render, routeMetadata } from "../dist-server/entry-server.js";

const template = await readFile("dist/index.html", "utf8");
const escape = (value) => String(value).replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
for (const path of routes) {
const { title, canonical, tags, graph } = routeMetadata(path);
const head = [
'<title>' + escape(title) + '</title>',
'<link rel="canonical" href="' + escape(canonical) + '">',
...Object.entries(tags).map(([key, value]) => '<meta ' + (key.startsWith("og:") ? "property" : "name") + '="' + key + '" content="' + escape(value) + '">'),
'<script id="page-structured-data" type="application/ld+json">' + graph + '</script>',
].join("\n");
const body = render(path);
if (!body.includes("<main") || !body.includes("<h1")) throw new Error("Missing public page content for " + path);
const output = "dist/" + path.replace(/^\/|\/$/g, "") + "/index.html";
await mkdir(dirname(output), { recursive: true });
await writeFile(output, template
.replace(/<meta (?:property="og:[^"]+"|name="(?:description|twitter:[^"]+)")[^>]*>/g, "")
.replace(/<link rel="canonical"[^>]*>/g, "")
.replace(/<script id="json-ld-schema"[^>]*>[\s\S]*?<\/script>/g, "")
.replace(/<title>[^<]*<\/title>/, () => head)
.replace('<div id="root"></div>', () => '<div id="root">' + body + '</div>'));
}
console.log("Verified " + routes.length + " prerendered routes");
Loading
Loading