#Passing arguments/options to plugins

1 messages · Page 1 of 1 (latest)

spring knoll
#

I'm trying to pass arguments to starlightSiteGraph().

The source for the project's page does this:

plugins: [
                starlightLinksValidator({
                    errorOnInvalidHashes: false
                }),
                starlightThemeObsidian({
                    debug: false,
                    graphConfig: {
                        depth: 1,
                        scale: 1,
                        labelOpacityScale: 1.5,
                        labelFontSize: 11,
                        labelHoverScale: 1.3,
                        renderArrows: true,
                        tagRenderMode: 'same',
                    },
                    sitemapConfig: {
                        includeExternalLinks: true
                    }
                }),
            ],

But when I do this:

            plugins: [
                starlightSiteGraph({
                    graphConfig: {}
            }),
                ion()
            ],

I get this error in terminal:


> [email protected] preview
> npx astro build && npx vite preview

19:42:47 [ERROR] [@astrojs/starlight] An unhandled error occurred while running the "astro:config:setup" hook
[AstroUserError] Invalid options passed to "starlight-site-graph-integration" integration

  Hint:
    Invalid input: expected map, received object

How can I fix this?

bitter vergeBOT
#

Hi @spring knoll. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The error you're seeing — Invalid input: expected map, received object — is coming from the starlight-site-graph plugin's own internal validation, not from Astro or Starlight's core plugin API. This means the issue is with how starlightSiteGraph() expects its options to be structured, not with how Starlight plugins work in general.

The knowledge sources available to me don't include documentation for starlight-site-graph specifically, so I can't tell you exactly what shape graphConfig needs to be for that plugin. [Community plugins]

Here are some steps to investigate and fix the issue:

  1. Check the plugin's own documentation/README on its GitHub page (starlight-site-graph) for the correct option types and structure.
  2. Pass an empty object or omit the option entirely to see if the plugin works without graphConfig:
    plugins: [
      starlightSiteGraph(),
      ion()
    ],
    
  3. Look at the plugin's TypeScript types — the error "expected map, received object" often comes from a Zod schema validation where the plugin expects a specific type (like a Map) rather than a plain object literal {}.

The Starlight plugin API itself supports passing options to plugins via factory functions [Plugins Reference], so the pattern you're using is correct in principle. The problem is specific to how starlight-site-graph validates its input. I'd recommend opening an issue on the plugin's GitHub repository if the documentation doesn't clarify the expected format.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@spring knoll Kapa.ai is still learning and improving, please let me know how I did by reacting below.

spring knoll
#

@bitter verge The starlightSiteGraph documentation mentions:
plugins: [starlightSiteGraph({ ... })],
is the way to configure it with starlight.

bitter vergeBOT
#

Let me check the knowledge base for you again. One moment! :books:

#

The pattern plugins: [starlightSiteGraph({ ... })] is indeed the standard way to add a Starlight plugin with options. [Plugins Reference] This is consistent with how all Starlight plugins work.

However, the error you're encountering (Invalid input: expected map, received object) is coming from starlight-site-graph's own internal validation of the options you're passing — specifically the graphConfig: {} value. The plugin appears to expect a different type for that field than a plain empty object.

Unfortunately, the knowledge sources I have access to don't include the starlight-site-graph plugin's documentation or source code, so I can't tell you exactly what value graphConfig expects. I'd recommend:

  1. Checking the plugin's README on its GitHub page for the correct structure and types for graphConfig.
  2. Trying without graphConfig to confirm the plugin loads correctly on its own:
    plugins: [starlightSiteGraph()],
    
  3. Reaching out on the Astro Discord in the #starlight channel, where community members familiar with this plugin may be able to help. [Troubleshooting Starlight]

The issue is not with how Starlight handles plugin options — it's specific to what starlight-site-graph accepts for graphConfig.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: