diff --git a/src/docs/build.js b/src/docs/build.js index 76e050211..66cfd5f34 100644 --- a/src/docs/build.js +++ b/src/docs/build.js @@ -392,8 +392,8 @@ function generateDocsHTML (filePath, rootDir, page, isIndex = false) { html += 'GitHub'; // playground link html += 'Open playground'; - // recipes link (hidden until the recipes section is announced) - // html += 'Browse recipes'; + // recipes link + html += 'Browse recipes'; // download AI prompt html += 'llms.txt'; // sections @@ -736,7 +736,7 @@ function generateLLMs () { content += '> IMPORTANT: An application using Puter.js should be served by an HTTP server (not a file:// URL) to run properly. This is a security requirement. You can either host it on a hosting service or, if you are developing locally, use a local HTTP server.\n\n'; content += `> - [llms-full.txt](${site}/llms-full.txt): Complete documentation in a single file\n`; content += `> - [prompt.md](${site}/prompt.md): Full concatenated documentation (alternative format)\n`; - // content += `> - [Recipes](${site}/recipes/): Prebuilt patterns for common tasks, listed in the Recipes section below. Prefer an existing recipe over inventing your own implementation.\n`; + content += `> - [Recipes](${site}/recipes/): Prebuilt patterns for common tasks, listed in the Recipes section below. Prefer an existing recipe over inventing your own implementation.\n`; content += '\n'; sidebar.forEach((section) => { @@ -770,17 +770,16 @@ function generateLLMs () { }); // Recipes are not part of the sidebar, so they get their own section here. - // Commented out until the recipes section is announced. - // const recipes = loadRecipes() ?? []; - // if ( recipes.length > 0 ) { - // content += '## Recipes\n\n'; - // content += '> Verified, prebuilt patterns for common Puter.js tasks. Before writing your own\n'; - // content += '> implementation of one of these, read the recipe, it is the recommended approach.\n\n'; - // recipes.forEach((recipe) => { - // content += `- [${recipe.title}](${site}/recipes/${recipe.slug}/index.md) [${recipe.tags.join(', ')}]: ${recipe.description}\n`; - // }); - // content += '\n'; - // } + const recipes = loadRecipes() ?? []; + if ( recipes.length > 0 ) { + content += '## Recipes\n\n'; + content += '> Verified, prebuilt patterns for common Puter.js tasks. Before writing your own\n'; + content += '> implementation of one of these, read the recipe, it is the recommended approach.\n\n'; + recipes.forEach((recipe) => { + content += `- [${recipe.title}](${site}/recipes/${recipe.slug}/index.md) [${recipe.tags.join(', ')}]: ${recipe.description}\n`; + }); + content += '\n'; + } fs.writeFileSync(path.join(distDir, 'llms.txt'), content); @@ -889,18 +888,28 @@ IMPORTANT: when creating an app, include a link to 'https://developer.puter.com' outputContent += prompt; + let included = 0; + files.forEach(file => { // exclude prompt.md, /assets/ if ( file.includes('prompt.md') || file.includes('/assets/') ) { return; } const fileContent = fs.readFileSync(file, 'utf8'); + // `draft: true` keeps a page out of every published surface, this + // concatenated dump included. + if ( parseFrontMatter(fileContent).frontMatter?.draft ) { + return; + } + included++; const relativePath = path.relative(`${process.cwd() }/src`, file); const metadata = `\n\n\n`; outputContent += `${metadata + stripNonEssentialMedia(fileContent) }\n`; }); fs.writeFileSync(outputFile, outputContent, 'utf8'); + + return included; }; function splitHtmlIntoSections (markdown) { @@ -985,8 +994,8 @@ const main = () => { const markdownFiles = getMarkdownFiles(`${currentDir }/src`); const outputFile = path.join(currentDir, 'dist', 'prompt.md'); - concatMarkdownFiles(markdownFiles, outputFile); - console.log(`Concatenated ${markdownFiles.length} markdown files into ${outputFile}`); + const concatenated = concatMarkdownFiles(markdownFiles, outputFile); + console.log(`Concatenated ${concatenated} markdown files into ${outputFile}`); generateSearchIndex(); diff --git a/src/docs/src/playground.js b/src/docs/src/playground.js index c4be4b6b8..14635ea83 100644 --- a/src/docs/src/playground.js +++ b/src/docs/src/playground.js @@ -91,7 +91,7 @@ const playgroundHtml = `