From 59be4ad237d6dff5ac91c280e520113cf33076e9 Mon Sep 17 00:00:00 2001 From: Reynaldi Chernando <12949382+reynaldichernando@users.noreply.github.com> Date: Thu, 10 Sep 2026 01:07:26 +0700 Subject: [PATCH] more recipes (#3819) * more recipes * addition * final * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * styling fix --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/docs/build.js | 41 +++-- src/docs/src/playground.js | 2 +- src/docs/src/recipes.js | 15 +- src/docs/src/recipes/assets/css/style.css | 25 --- src/docs/src/recipes/host-file.md | 103 ++++++++++++ src/docs/src/recipes/kv-append-to-list.md | 15 +- src/docs/src/recipes/kv-edit-items-by-id.md | 105 ------------ src/docs/src/recipes/kv-prefix-listing.md | 121 -------------- src/docs/src/recipes/query-collection.md | 137 +++++++++++++++ src/docs/src/recipes/store-data.md | 107 ++++++++++++ src/docs/src/recipes/store-files.md | 145 ++++++++++++++++ .../src/recipes/store-large-collection.md | 157 ++++++++++++++++++ .../src/recipes/store-server-side-data.md | 115 +++++++++++++ src/docs/src/recipes/store-small-list.md | 83 +++++++++ 14 files changed, 892 insertions(+), 279 deletions(-) create mode 100644 src/docs/src/recipes/host-file.md delete mode 100644 src/docs/src/recipes/kv-edit-items-by-id.md delete mode 100644 src/docs/src/recipes/kv-prefix-listing.md create mode 100644 src/docs/src/recipes/query-collection.md create mode 100644 src/docs/src/recipes/store-data.md create mode 100644 src/docs/src/recipes/store-files.md create mode 100644 src/docs/src/recipes/store-large-collection.md create mode 100644 src/docs/src/recipes/store-server-side-data.md create mode 100644 src/docs/src/recipes/store-small-list.md 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 = `
- Prebuilt patterns for common Puter.js tasks — the recommended way to do - each of these. Copy one rather than working it out from the API reference. + Build specific Puter.js features with recipes from Puter + and the community.
${encode(recipe.description)}