From bb4a1214ebc40ecdffbfeff0f73ab9ce1575ab81 Mon Sep 17 00:00:00 2001 From: John Lindquist Date: Tue, 2 Jan 2024 15:58:31 -0700 Subject: [PATCH] fix(featured): updating featured scripts --- apps/scriptkit/featured.json | 20 ++++++------ .../scriptkit/src/components/scripts/card.tsx | 2 +- apps/scriptkit/src/pages/index.tsx | 31 ++++++++++++++++--- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/apps/scriptkit/featured.json b/apps/scriptkit/featured.json index 9d4ea1f..5b5cc1e 100644 --- a/apps/scriptkit/featured.json +++ b/apps/scriptkit/featured.json @@ -1,26 +1,26 @@ [ { - "user": "johnlindquist", - "command": "giphy-search" + "user": "kentcdodds", + "command": "new-post" }, { "user": "johnlindquist", - "command": "image-resize" + "command": "giphy-search" }, { - "user": "johnlindquist", - "command": "center-app" + "user": "laura-ok", + "command": "natural-language-shell-command" }, { - "user": "johnlindquist", - "command": "reddit" + "user": "mabry1985", + "command": "prompt-anywhere-v2" }, { - "user": "johnlindquist", - "command": "book-search" + "user": "kentcdodds", + "command": "extract-text-from-images" }, { "user": "johnlindquist", - "command": "app-launcher" + "command": "image-resize" } ] diff --git a/apps/scriptkit/src/components/scripts/card.tsx b/apps/scriptkit/src/components/scripts/card.tsx index 9ea1608..46c884f 100644 --- a/apps/scriptkit/src/components/scripts/card.tsx +++ b/apps/scriptkit/src/components/scripts/card.tsx @@ -29,7 +29,7 @@ const ScriptCard: FunctionComponent<

- {script.command} + {script.title}

{withAuthor && (
diff --git a/apps/scriptkit/src/pages/index.tsx b/apps/scriptkit/src/pages/index.tsx index aa6d050..c0ae4da 100644 --- a/apps/scriptkit/src/pages/index.tsx +++ b/apps/scriptkit/src/pages/index.tsx @@ -186,6 +186,10 @@ const Home: FunctionComponent> = ({

Key Features

    +
  • + ▪︎ + Write your scripts in TypeScript with our SDK. Zero config. +
  • ▪︎ Launch the prompt from anywhere as part of your flow @@ -214,9 +218,9 @@ const Home: FunctionComponent> = ({
  • ▪︎ - Load npm libraries:{''} + Watches your scripts and prompts to install npm libraries:{''} - await npm("sharp") + import express from "express"
  • @@ -337,10 +341,27 @@ export async function getStaticProps(context: any) { const scripts = await getAllScripts() - const featuredScripts = scripts.filter((s) => { - return selectedScripts.find( - (ss) => ss.user === s.user && ss.command === s.command, + const featuredScriptsSet = new Set( + selectedScripts.map((ss) => `${ss.user}/${ss.command}`), + ) + const featuredScripts = [] + for (const script of scripts) { + const scriptIdentifier = `${script.user}/${script.command}` + if (featuredScriptsSet.has(scriptIdentifier)) { + featuredScripts.push(script) + featuredScriptsSet.delete(scriptIdentifier) // Ensure uniqueness + } + } + + // Sort featuredScripts by order in selectedScripts + featuredScripts.sort((a, b) => { + const aIndex = selectedScripts.findIndex( + (ss) => ss.user === a.user && ss.command === a.command, + ) + const bIndex = selectedScripts.findIndex( + (ss) => ss.user === b.user && ss.command === b.command, ) + return aIndex - bIndex }) const testimonials = await getTestimonials()