google search index
All checks were successful
CI — Website / Website — typecheck, build (pull_request) Successful in 57s

This commit is contained in:
john kevin asprec
2026-09-03 21:40:55 +08:00
parent 2eb6eed16a
commit 3150e16248
23 changed files with 406 additions and 29 deletions

View File

@@ -28,7 +28,7 @@ Preview production build locally: `npm run website:preview` (Vite, localhost onl
Production start (what Coolify should run): `npm start` — serves `dist/` on `0.0.0.0:$PORT` (default 3000).
Uses HashRouter so deep links work even without SPA rewrite rules. The production server still maps unknown paths to `index.html`.
Uses BrowserRouter. Production nginx/Node serve `/docs`, `/contribute`, and `/community` as real paths (legacy `#/docs` links rewrite on load). Unknown paths return HTTP 404.
## Deploy on Coolify
@@ -44,7 +44,7 @@ This package is a static Vite build. No LexAI API keys or env vars. Do not add `
4. Branch: `dev` or `main`.
5. **Base Directory:** `packages/website` — no leading slash. Root `npm run build` builds Chrome, not this site.
6. Optional **Watch Paths:** `packages/website`.
7. Set the domain, deploy, open `https://your-domain/` (docs: `https://your-domain/#/docs`).
7. Set the domain, deploy, open `https://lexai.juankibin.space/` (docs: `/docs`).
### Option A — Dockerfile (recommended)
@@ -66,3 +66,13 @@ Do **not** tick "Is it a static site?" with Publish Directory `/dist`. The leadi
If you already created the resource: uncheck static site, set Base Directory and port as above, then Redeploy (no need to recreate the app).
Auto-deploy: Coolify resource → **Webhooks** → copy the URL + secret into Gitea **Settings → Webhooks** (push events).
## Google Search
After the site is live on `https://lexai.juankibin.space/`:
1. Open [Google Search Console](https://search.google.com/search-console), add a URL-prefix property for that origin, and verify (HTML file or DNS).
2. Sitemaps → submit `https://lexai.juankibin.space/sitemap.xml`.
3. URL inspection → request indexing for `/` and `/docs`.
Crawlers should see `Allow: /` at `/robots.txt` and unique titles on `/`, `/docs`, `/contribute`, and `/community`.

View File

@@ -30,7 +30,7 @@ Pick a pattern (role, chain-of-thought, and more), set persona and output format
Same BYO-key model: your API key, your provider, no LexAI servers.
Try it: https://lexai.juankibin.space/
Docs: https://lexai.juankibin.space/#/docs
Docs: https://lexai.juankibin.space/docs
#PromptEngineering #AI #OpenSource #DeveloperTools #BYOLLM
@@ -189,7 +189,7 @@ LexAI is an open-source toolkit for people who already have an LLM API key — a
No LexAI backend, account, or telemetry. Keys stay on-device (encrypted in Chrome, Secret Storage in VS Code).
Site: https://lexai.juankibin.space/
Docs: https://lexai.juankibin.space/#/docs
Docs: https://lexai.juankibin.space/docs
Repo: https://git.juankibin.space/kibin/LexAI
Chrome: https://chromewebstore.google.com/detail/bagpcheidbkfgijnnmolnkgagibbjfnk
VS Code: https://marketplace.visualstudio.com/items?itemName=JuanKibin.lexai-vscode

View File

@@ -3,10 +3,27 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="robots" content="index, follow" />
<meta
name="description"
content="LexAI — bring-your-own-LLM writing and code assist. Chrome, VS Code, and CLI. No LexAI servers, no subscription."
/>
<link rel="canonical" href="https://lexai.juankibin.space/" />
<meta property="og:type" content="website" />
<meta property="og:site_name" content="LexAI" />
<meta property="og:title" content="LexAI — BYO-LLM writing &amp; code assist" />
<meta
property="og:description"
content="LexAI — bring-your-own-LLM writing and code assist. Chrome, VS Code, and CLI. No LexAI servers, no subscription."
/>
<meta property="og:url" content="https://lexai.juankibin.space/" />
<meta property="og:image" content="https://lexai.juankibin.space/icon.svg" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="LexAI — BYO-LLM writing &amp; code assist" />
<meta
name="twitter:description"
content="LexAI — bring-your-own-LLM writing and code assist. Chrome, VS Code, and CLI. No LexAI servers, no subscription."
/>
<link rel="icon" type="image/svg+xml" href="/icon.svg" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
@@ -14,7 +31,28 @@
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap"
rel="stylesheet"
/>
<title>LexAI — BYO-LLM writing & code assist</title>
<title>LexAI — BYO-LLM writing &amp; code assist</title>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "WebSite",
"name": "LexAI",
"url": "https://lexai.juankibin.space/",
"description": "Bring-your-own-LLM writing and code assist for Chrome, VS Code, and the CLI."
},
{
"@type": "SoftwareApplication",
"name": "LexAI",
"applicationCategory": "BrowserApplication",
"operatingSystem": "Chrome, VS Code, Windows, macOS, Linux",
"url": "https://lexai.juankibin.space/",
"offers": { "@type": "Offer", "price": "0", "priceCurrency": "USD" }
}
]
}
</script>
</head>
<body>
<div id="root"></div>

View File

@@ -0,0 +1,69 @@
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
const root = dirname(fileURLToPath(import.meta.url));
const distHtml = join(root, 'dist', 'index.html');
const { origin, routes } = JSON.parse(
readFileSync(join(root, 'src', 'seo.routes.json'), 'utf8'),
);
function apply(html, { title, description, url, robots }) {
let out = html;
out = out.replace(/<title>[\s\S]*?<\/title>/, `<title>${title}</title>`);
out = out.replace(
/(<meta\s+name="description"\s+content=")[^"]*(")/,
`$1${description}$2`,
);
out = out.replace(/(<meta\s+name="robots"\s+content=")[^"]*(")/, `$1${robots}$2`);
out = out.replace(/(<meta\s+property="og:title"\s+content=")[^"]*(")/, `$1${title}$2`);
out = out.replace(
/(<meta\s+property="og:description"\s+content=")[^"]*(")/,
`$1${description}$2`,
);
out = out.replace(/(<meta\s+property="og:url"\s+content=")[^"]*(")/, `$1${url}$2`);
out = out.replace(/(<meta\s+name="twitter:title"\s+content=")[^"]*(")/, `$1${title}$2`);
out = out.replace(
/(<meta\s+name="twitter:description"\s+content=")[^"]*(")/,
`$1${description}$2`,
);
out = out.replace(/(<link\s+rel="canonical"\s+href=")[^"]*(")/, `$1${url}$2`);
return out;
}
const template = readFileSync(distHtml, 'utf8');
if (!template.includes('rel="canonical"') || !template.includes('og:title')) {
console.error('dist/index.html is missing SEO tags — check index.html');
process.exit(1);
}
const written = [];
for (const route of routes) {
const url = route.path === '/' ? `${origin}/` : `${origin}${route.path}`;
const file = route.path === '/' ? 'index.html' : `${route.path.replace(/^\//, '')}/index.html`;
const dest = join(root, 'dist', file);
mkdirSync(dirname(dest), { recursive: true });
writeFileSync(
dest,
apply(template, {
title: route.title,
description: route.description,
url,
robots: 'index, follow',
}),
);
written.push(file);
}
writeFileSync(
join(root, 'dist', '404.html'),
apply(template, {
title: 'Page not found — LexAI',
description: 'That address is not a LexAI page.',
url: `${origin}/`,
robots: 'noindex, follow',
}),
);
written.push('404.html');
console.log('SEO HTML written for', written.join(', '));

View File

@@ -10,7 +10,26 @@ server {
return 200 'ok';
}
location / {
location = /robots.txt {
try_files /robots.txt =404;
}
location = /sitemap.xml {
default_type application/xml;
try_files /sitemap.xml =404;
}
location ~ ^/(docs|contribute|community)/?$ {
try_files $uri $uri/ /index.html;
}
error_page 404 =404 /404.html;
location = /404.html {
internal;
}
location / {
try_files $uri $uri/ =404;
}
}

View File

@@ -8,7 +8,7 @@
},
"scripts": {
"dev": "vite",
"build": "tsc --noEmit && vite build",
"build": "tsc --noEmit && vite build && node inject-seo.mjs",
"preview": "vite preview",
"start": "node server.mjs",
"typecheck": "tsc --noEmit"

View File

@@ -0,0 +1,4 @@
User-agent: *
Allow: /
Sitemap: https://lexai.juankibin.space/sitemap.xml

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://lexai.juankibin.space/</loc>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://lexai.juankibin.space/docs</loc>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://lexai.juankibin.space/contribute</loc>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://lexai.juankibin.space/community</loc>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
</urlset>

View File

@@ -20,8 +20,21 @@ const MIME = {
'.webp': 'image/webp',
'.woff': 'font/woff',
'.woff2': 'font/woff2',
'.xml': 'application/xml; charset=utf-8',
};
const SPA_ROUTES = new Set(['/', '/docs', '/contribute', '/community']);
function requestPath(urlPath) {
const decoded = decodeURIComponent((urlPath ?? '/').split('?')[0] || '/');
if (decoded.length > 1 && decoded.endsWith('/')) return decoded.slice(0, -1) || '/';
return decoded || '/';
}
function isSpaRoute(urlPath) {
return SPA_ROUTES.has(requestPath(urlPath));
}
function fileUnderRoot(urlPath) {
const decoded = decodeURIComponent((urlPath ?? '/').split('?')[0] || '/');
const relative = decoded.replace(/^\/+/, '').replaceAll('/', sep);
@@ -54,8 +67,14 @@ const server = createServer((req, res) => {
}
let file = candidate;
if (!existsSync(file) || statSync(file).isDirectory()) {
file = join(root, 'index.html');
let status = 200;
if (existsSync(file) && statSync(file).isDirectory()) {
const nested = join(file, 'index.html');
file = existsSync(nested) ? nested : join(root, 'index.html');
} else if (!existsSync(file)) {
const notFound = join(root, '404.html');
file = existsSync(notFound) && !isSpaRoute(req.url ?? '/') ? notFound : join(root, 'index.html');
if (!isSpaRoute(req.url ?? '/')) status = 404;
}
if (!existsSync(file)) {
send(res, 500, 'dist/ missing — run npm run build before start');
@@ -63,7 +82,7 @@ const server = createServer((req, res) => {
}
const type = MIME[extname(file).toLowerCase()] ?? 'application/octet-stream';
res.writeHead(200, { 'Content-Type': type });
res.writeHead(status, { 'Content-Type': type });
if (req.method === 'HEAD') {
res.end();
return;

View File

@@ -1,14 +1,17 @@
import { Navigate, Route, Routes } from 'react-router-dom';
import { Route, Routes } from 'react-router-dom';
import { SeoHead } from './components/SeoHead';
import { SiteHeader } from './components/SiteHeader';
import { SiteFooter } from './components/SiteFooter';
import { HomePage } from './pages/HomePage';
import { DocsPage } from './pages/DocsPage';
import { ContributePage } from './pages/ContributePage';
import { CommunityPage } from './pages/CommunityPage';
import { NotFoundPage } from './pages/NotFoundPage';
export default function App() {
return (
<div className="shell">
<SeoHead />
<SiteHeader />
<main>
<Routes>
@@ -16,7 +19,7 @@ export default function App() {
<Route path="/docs" element={<DocsPage />} />
<Route path="/contribute" element={<ContributePage />} />
<Route path="/community" element={<CommunityPage />} />
<Route path="*" element={<Navigate to="/" replace />} />
<Route path="*" element={<NotFoundPage />} />
</Routes>
</main>
<SiteFooter />

View File

@@ -0,0 +1,47 @@
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import { canonicalUrl, seoForPath, SITE_ORIGIN } from '../seo';
function upsertMeta(selector: string, attrs: Record<string, string>, content: string) {
let el = document.head.querySelector(selector) as HTMLMetaElement | null;
if (!el) {
el = document.createElement('meta');
for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, v);
document.head.appendChild(el);
}
el.setAttribute('content', content);
}
function upsertCanonical(href: string) {
let el = document.head.querySelector('link[rel="canonical"]') as HTMLLinkElement | null;
if (!el) {
el = document.createElement('link');
el.rel = 'canonical';
document.head.appendChild(el);
}
el.href = href;
}
export function SeoHead() {
const { pathname } = useLocation();
useEffect(() => {
const seo = seoForPath(pathname);
const url = seo.index ? canonicalUrl(seo.path) : `${SITE_ORIGIN}${pathname}`;
document.title = seo.title;
upsertMeta('meta[name="description"]', { name: 'description' }, seo.description);
upsertMeta(
'meta[name="robots"]',
{ name: 'robots' },
seo.index ? 'index, follow' : 'noindex, follow',
);
upsertCanonical(url);
upsertMeta('meta[property="og:title"]', { property: 'og:title' }, seo.title);
upsertMeta('meta[property="og:description"]', { property: 'og:description' }, seo.description);
upsertMeta('meta[property="og:url"]', { property: 'og:url' }, url);
upsertMeta('meta[name="twitter:title"]', { name: 'twitter:title' }, seo.title);
upsertMeta('meta[name="twitter:description"]', { name: 'twitter:description' }, seo.description);
}, [pathname]);
return null;
}

View File

@@ -1,13 +1,19 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { HashRouter } from 'react-router-dom';
import { BrowserRouter } from 'react-router-dom';
import App from './App';
import './styles.css';
const hash = window.location.hash;
if (hash.startsWith('#/')) {
const path = hash.slice(1) || '/';
window.history.replaceState(null, '', path + window.location.search);
}
createRoot(document.getElementById('root')!).render(
<StrictMode>
<HashRouter>
<BrowserRouter>
<App />
</HashRouter>
</BrowserRouter>
</StrictMode>,
);

View File

@@ -0,0 +1,20 @@
import { Link } from 'react-router-dom';
export function NotFoundPage() {
return (
<div className="wrap page">
<article className="docs-content">
<h1>Page not found</h1>
<p className="intro">That address is not a LexAI page. Check the URL or go back home.</p>
<div className="cta-row">
<Link className="btn btn-primary" to="/">
Home
</Link>
<Link className="btn btn-ghost" to="/docs">
Docs
</Link>
</div>
</article>
</div>
);
}

View File

@@ -0,0 +1,25 @@
{
"origin": "https://lexai.juankibin.space",
"routes": [
{
"path": "/",
"title": "LexAI — BYO-LLM writing & code assist",
"description": "LexAI — bring-your-own-LLM writing and code assist. Chrome, VS Code, and CLI. No LexAI servers, no subscription."
},
{
"path": "/docs",
"title": "Docs — LexAI",
"description": "Install and use LexAI in Chrome, VS Code, and the CLI. Free LLM setup, privacy, and the shared core."
},
{
"path": "/contribute",
"title": "Contribute — LexAI",
"description": "How to report bugs, set up the LexAI monorepo, and send focused pull requests."
},
{
"path": "/community",
"title": "Community — LexAI",
"description": "LexAI source, issues, Chrome Web Store, VS Code Marketplace, and Code of Conduct."
}
]
}

View File

@@ -0,0 +1,34 @@
import routesFile from './seo.routes.json';
export const SITE_ORIGIN = routesFile.origin;
export type SeoRoute = {
path: string;
title: string;
description: string;
index: boolean;
};
export const INDEXABLE_ROUTES: SeoRoute[] = routesFile.routes.map((r) => ({
...r,
index: true,
}));
export const NOT_FOUND_SEO: SeoRoute = {
path: '',
title: 'Page not found — LexAI',
description: 'That address is not a LexAI page.',
index: false,
};
const byPath = new Map(INDEXABLE_ROUTES.map((r) => [r.path, r]));
export function seoForPath(pathname: string): SeoRoute {
const normalized = pathname.replace(/\/+$/, '') || '/';
return byPath.get(normalized) ?? NOT_FOUND_SEO;
}
export function canonicalUrl(path: string): string {
if (!path || path === '/') return `${SITE_ORIGIN}/`;
return `${SITE_ORIGIN}${path.startsWith('/') ? path : `/${path}`}`;
}

View File

@@ -7,6 +7,7 @@
"skipLibCheck": true,
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,