diff --git a/src/content/docs/docs/flows.mdx b/src/content/docs/docs/flows.mdx index 9f038018..0f9f22e9 100644 --- a/src/content/docs/docs/flows.mdx +++ b/src/content/docs/docs/flows.mdx @@ -1,4 +1,3 @@ - --- title: Defining AI workflows description: Learn how to define and manage AI workflows in Genkit using flows across JavaScript, Go, and Python, which provide type safety, integration with the developer UI, and simplified deployment. diff --git a/src/gen-bundle.ts b/src/gen-bundle.ts index 2994cca9..d1d1f997 100644 --- a/src/gen-bundle.ts +++ b/src/gen-bundle.ts @@ -21,9 +21,9 @@ import { parse } from 'yaml'; export const FRONTMATTER_AND_BODY_REGEX = /^---\s*(?:\r\n|\r|\n)([\s\S]*?)(?:\r\n|\r|\n)---\s*(?:\r\n|\r|\n)([\s\S]*)$/; async function main() { - const allDocs = await indexDocs('src/content/docs/docs'); const documents: Record = {}; for (const lang of ['js', 'go', 'python']) { + const allDocs = await indexDocs('src/content/docs/docs', lang); for (const doc of Object.keys(allDocs)) { documents[`${lang}/${doc}`] = { ...allDocs[doc], @@ -38,11 +38,12 @@ interface Doc { title: string; description?: string; text: string; + url: string; headers: string; lang: string; } -async function indexDocs(dir: string) { +async function indexDocs(dir: string, lang: string) { const allFiles = await readdir(dir, { recursive: true }); const docFiles = allFiles.filter((f) => f.endsWith('.md') || f.endsWith('.mdx')); const documents: Record> = {}; @@ -54,7 +55,9 @@ async function indexDocs(dir: string) { const normalizedFileName = file.endsWith('.mdx') ? file.substring(0, file.length - 1) : file; documents[normalizedFileName] = { - text: renderContent(file, body, frontmatter.title || normalizedFileName), + text: renderContent(file, body, frontmatter.title || normalizedFileName, lang), + url: + 'https://genkit.dev/docs/' + normalizedFileName.substring(0, normalizedFileName.lastIndexOf('.')) + '/', title: frontmatter.title || normalizedFileName, description: frontmatter.description, headers, @@ -66,8 +69,19 @@ async function indexDocs(dir: string) { const LLM_SUMMARY_REGEX = /([\s\S]*?)<\/LLMSummary>/; const FRONTMATTER_REGEX = /^---\s*[\s\S]*?---/; -function renderContent(file: string, rawContent: string, title: string) { +function renderContent(file: string, rawContent: string, title: string, lang: string) { if (file.endsWith('.mdx')) { + // Strip out content for other languages + rawContent = rawContent.replace( + /]*>([\s\S]*?)<\/LanguageContent>/g, + (match, blockLang, content) => { + if (blockLang === lang) { + return content; + } + return ''; + }, + ); + // --- Check for tag --- const llmMatch = rawContent.match(LLM_SUMMARY_REGEX);