|
|
import { resolve } from 'node:path' |
|
|
import { fileURLToPath } from 'node:url' |
|
|
import { readFileSync, writeFileSync } from 'node:fs' |
|
|
import { generateReferenceDocs } from '@tanstack/config/typedoc' |
|
|
import { glob } from 'tinyglobby' |
|
|
|
|
|
const __dirname = fileURLToPath(new URL('.', import.meta.url)) |
|
|
|
|
|
await generateReferenceDocs({ |
|
|
packages: [ |
|
|
{ |
|
|
name: 'angular-query-experimental', |
|
|
entryPoints: [ |
|
|
resolve( |
|
|
__dirname, |
|
|
'../packages/angular-query-experimental/src/index.ts', |
|
|
), |
|
|
], |
|
|
tsconfig: resolve( |
|
|
__dirname, |
|
|
'../packages/angular-query-experimental/tsconfig.json', |
|
|
), |
|
|
outputDir: resolve(__dirname, '../docs/framework/angular/reference'), |
|
|
exclude: ['./packages/query-core/**/*'], |
|
|
}, |
|
|
{ |
|
|
name: 'svelte-query', |
|
|
entryPoints: [ |
|
|
resolve(__dirname, '../packages/svelte-query/src/index.ts'), |
|
|
], |
|
|
tsconfig: resolve(__dirname, '../packages/svelte-query/tsconfig.json'), |
|
|
outputDir: resolve(__dirname, '../docs/framework/svelte/reference'), |
|
|
exclude: ['./packages/query-core/**/*'], |
|
|
}, |
|
|
], |
|
|
}) |
|
|
|
|
|
|
|
|
const markdownFilesPattern = 'docs/framework/{angular,svelte}/reference/**/*.md' |
|
|
|
|
|
|
|
|
const markdownFiles = await glob(markdownFilesPattern) |
|
|
|
|
|
console.log(`Found ${markdownFiles.length} markdown files to process\n`) |
|
|
|
|
|
|
|
|
markdownFiles.forEach((file) => { |
|
|
const content = readFileSync(file, 'utf-8') |
|
|
let updatedContent = content |
|
|
updatedContent = updatedContent.replaceAll(/\]\(\.\.\//gm, '](../../') |
|
|
|
|
|
updatedContent = updatedContent.replaceAll( |
|
|
/\]\((?!https?:\/\/|\/\/|\/|\.\/|\.\.\/|#)([^)]+)\)/gm, |
|
|
(match, p1) => `](../${p1})`, |
|
|
) |
|
|
|
|
|
|
|
|
if (updatedContent !== content) { |
|
|
writeFileSync(file, updatedContent, 'utf-8') |
|
|
console.log(`Processed file: ${file}`) |
|
|
} |
|
|
}) |
|
|
|
|
|
console.log('\n✅ All markdown files have been processed!') |
|
|
|
|
|
process.exit(0) |
|
|
|