Skip to content

Merge markdown.config when extending existing config #4851

@sevenc-nanashi

Description

@sevenc-nanashi

Is your feature request related to a problem? Please describe.

I'm trying to create two plugins, which extends markdown feature.
And I'm trying to merge those two and my config, using extends like { extends: { extends: myPlugin1, ...myPlugin2 }, ...myPlugin3 }.

But I noticed that this solution does not work well because myPlugin1's markdown.config is replaced with myPlugin2's markdown.config.

Describe the solution you'd like

Merge markdown.config properly.
I'm using this mergeConfigs helper for now:

function mergeConfigs(
  ...configs: Omit<UserConfig<DefaultTheme.Config>, "extends">[]
): UserConfig<DefaultTheme.Config> {
  return configs.slice(1).reduce((merged, config) => {
    return {
      ...config,
      markdown: {
        config(md) {
          merged.markdown?.config?.(md);
          config.markdown?.config?.(md);
        },
      },
      extends: merged,
    };
  }, configs[0]);
}

Describe alternatives you've considered

None.

Additional context

Also it would be good if there's mergeConfigs by default.

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildRelated to the build systemcontribution welcomeThe team would welcome a contribution from the community for this issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions