From b2cccf636ab17fb82a9fc59f78457964bdad8a5b Mon Sep 17 00:00:00 2001 From: Ricardo Devis Agullo Date: Thu, 6 Nov 2025 13:10:22 +0100 Subject: [PATCH] add no robots option --- preview/fakeVM.ts | 2 ++ src/registry/domain/options-sanitiser.ts | 8 +++++++- src/registry/routes/component-info.ts | 3 ++- src/registry/routes/component-preview.ts | 1 + src/registry/views/index.tsx | 8 +++++++- src/registry/views/info.tsx | 9 ++++++++- src/registry/views/partials/layout.tsx | 15 +++++++++++++-- src/registry/views/preview.ts | 3 ++- src/types.ts | 7 +++++++ 9 files changed, 49 insertions(+), 7 deletions(-) diff --git a/preview/fakeVM.ts b/preview/fakeVM.ts index 5b329325..fd58a4f8 100644 --- a/preview/fakeVM.ts +++ b/preview/fakeVM.ts @@ -79,6 +79,7 @@ export const mockComponentHistory: ComponentHistory[] = [ // Mock data for Index VM (main registry page) export const mockIndexVM: IndexVm = { + robots: true, availableDependencies: [ { core: true, @@ -407,6 +408,7 @@ export const mockIndexVM: IndexVm = { // Mock data for Info VM (component detail page) export const mockInfoVM: InfoVm = { + robots: true, parsedAuthor: { name: 'Jane Smith', email: 'jane.smith@company.com', diff --git a/src/registry/domain/options-sanitiser.ts b/src/registry/domain/options-sanitiser.ts index 5c4a0d00..7b29d8cf 100644 --- a/src/registry/domain/options-sanitiser.ts +++ b/src/registry/domain/options-sanitiser.ts @@ -24,6 +24,7 @@ export interface RegistryOptions experimental?: boolean; api?: boolean; validate?: boolean; + robots?: boolean; } | boolean; /** @@ -85,6 +86,10 @@ export default function optionsSanitiser(input: RegistryOptions): Config { typeof options.discovery === 'boolean' ? options.discovery : (options.discovery?.ui ?? true); + const showRobots = + typeof options.discovery === 'boolean' + ? true + : (options.discovery?.robots ?? true); const showExperimental = !showApi ? false : typeof options.discovery === 'boolean' @@ -102,7 +107,8 @@ export default function optionsSanitiser(input: RegistryOptions): Config { ui: showUI, experimental: showExperimental, api: showApi, - validate: showValidation + validate: showValidation, + robots: showRobots }; if (typeof options.pollingInterval === 'undefined') { diff --git a/src/registry/routes/component-info.ts b/src/registry/routes/component-info.ts index dfb50d11..606600e1 100644 --- a/src/registry/routes/component-info.ts +++ b/src/registry/routes/component-info.ts @@ -85,7 +85,8 @@ function componentInfo( repositoryUrl, sandBoxDefaultQs: urlBuilder.queryString(params), title: 'Component Info', - theme + theme, + robots: res.conf.discovery.robots }) ); }); diff --git a/src/registry/routes/component-preview.ts b/src/registry/routes/component-preview.ts index 38798fab..91d1d709 100644 --- a/src/registry/routes/component-preview.ts +++ b/src/registry/routes/component-preview.ts @@ -32,6 +32,7 @@ function componentPreview( if (isHtmlRequest) { res.send( previewView({ + robots: res.conf.discovery.robots, component, importmap: getOcConfig(res.conf.path)?.development?.importmap, fallbackClient: res.conf.fallbackClient diff --git a/src/registry/views/index.tsx b/src/registry/views/index.tsx index c62eeea9..a999ef45 100644 --- a/src/registry/views/index.tsx +++ b/src/registry/views/index.tsx @@ -19,7 +19,13 @@ export default function indexView(vm: VM) { ${indexJS}`; return ( - +

OpenComponents Registry

diff --git a/src/registry/views/info.tsx b/src/registry/views/info.tsx index 1ba25a94..5803fbf8 100644 --- a/src/registry/views/info.tsx +++ b/src/registry/views/info.tsx @@ -18,6 +18,7 @@ export interface Vm { title: string; theme: 'light' | 'dark'; repositoryUrl: string | null; + robots: boolean; } function formatDate(date: Date | string) { @@ -224,7 +225,13 @@ export default function Info(vm: Vm) { `; return ( - +