Skip to content
Draft
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
Expand Up @@ -9,4 +9,5 @@ docs/.vitepress/dist
docs/.vitepress/cache
docs/public/gea-ui-showcase
website/docs
website/llms*.txt
.worktrees
5 changes: 3 additions & 2 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { defineConfig } from 'vitepress'
import llmstxt, { copyOrDownloadAsMarkdownButtons } from 'vitepress-plugin-llms'
import { moveLlmsTxtToOutDirParent } from './move-llms-txt-to-outdir-parent'

export default defineConfig({
vite: {
plugins: [llmstxt() as any],
plugins: [...(llmstxt() as any[]), moveLlmsTxtToOutDirParent() as any],
},
markdown: {
config(md) {
Expand All @@ -12,7 +13,7 @@ export default defineConfig({
},
title: 'Gea',
description: 'A lightweight, reactive JavaScript UI framework with compile-time JSX and proxy-based stores.',
base: '/docs/',
base: '/docs',
outDir: '../website/docs',
head: [
[
Expand Down
34 changes: 34 additions & 0 deletions docs/.vitepress/move-llms-txt-to-outdir-parent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import fs from 'node:fs/promises'
import path from 'node:path'

/**
* vitepress-plugin-llms always emits llms.txt / llms-full.txt into VitePress outDir.
* Move those two files to the parent folder (e.g. website/ next to website/docs/).
* Per-page *.md copies stay in outDir so URLs under `base` stay correct.
*/
export function moveLlmsTxtToOutDirParent() {
let outDir: string | undefined
let isSsrBuild = false
return {
name: 'move-llms-txt-to-outdir-parent',
apply: 'build' as const,
enforce: 'post' as const,
configResolved(resolved: { build: { ssr?: boolean }; vitepress?: { outDir?: string } }) {
outDir = resolved.vitepress?.outDir
isSsrBuild = Boolean(resolved.build.ssr)
},
async closeBundle() {
if (isSsrBuild || !outDir) return
const parent = path.dirname(path.resolve(outDir))
for (const name of ['llms.txt', 'llms-full.txt'] as const) {
const from = path.join(outDir, name)
const to = path.join(parent, name)
try {
await fs.rename(from, to)
} catch (e: unknown) {
if ((e as NodeJS.ErrnoException).code !== 'ENOENT') throw e
}
}
},
}
}
Loading