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
5 changes: 3 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"install:ci": "pnpm install --frozen-lockfile",
"dev": "vite",
"build": "tsc -b && vite build",
"build": "tsc -b && vite build && node scripts/inject-docs.mjs",
"preview": "vite preview",
"test": "vitest run",
"typecheck": "tsc --noEmit",
Expand All @@ -28,9 +28,9 @@
"react-dropzone": "^15.0.0",
"react-i18next": "^16.5.8",
"react-markdown": "^10.1.0",
"remark-frontmatter": "^5.0.0",
"rehype-highlight": "^7.0.2",
"rehype-sanitize": "^6.0.0",
"remark-frontmatter": "^5.0.0",
"remark-gfm": "^4.0.1",
"sonner": "^2.0.7",
"tailwind-merge": "^2.2.1",
Expand All @@ -48,6 +48,7 @@
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"marked": "^15.0.12",
"openapi-typescript": "^7.6.1",
"postcss": "^8.4.0",
"tailwindcss": "^3.4.0",
Expand Down
10 changes: 10 additions & 0 deletions web/pnpm-lock.yaml

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

45 changes: 45 additions & 0 deletions web/scripts/inject-docs.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env node

import { readFileSync, writeFileSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
import { marked } from 'marked';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

// Paths
const projectRoot = join(__dirname, '../..');
const docPath = join(projectRoot, 'docs/openclaw-integration-en.md');
const distIndexPath = join(__dirname, '../dist/index.html');

console.log('📄 Reading markdown document...');
const markdownContent = readFileSync(docPath, 'utf-8');

console.log('🔄 Converting markdown to HTML...');
const htmlContent = marked.parse(markdownContent);

console.log('📝 Reading dist/index.html...');
const indexHtml = readFileSync(distIndexPath, 'utf-8');

// Create the hidden SEO container
const seoContainer = `
<!-- SEO: Hidden documentation for web crawlers -->
<div id="seo-docs" style="position:absolute;left:-9999px;top:-9999px;overflow:hidden;width:1px;height:1px;" aria-hidden="true">
${htmlContent}
</div>
`;

// Inject before <div id="root">
const injectedHtml = indexHtml.replace(
/<div id="root">/,
`${seoContainer}\n <div id="root">`
);

console.log('💾 Writing updated index.html...');
writeFileSync(distIndexPath, injectedHtml, 'utf-8');

console.log('✅ Documentation injected successfully!');
console.log(` - Source: ${docPath}`);
console.log(` - Target: ${distIndexPath}`);
console.log(` - Content size: ~${Math.round(htmlContent.length / 1024)}KB`);
Loading