Skip to content

Add the ability to add custom classes to api-method sidebar items #893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

tyler-mairose-sp
Copy link
Contributor

Add the ability to customize the sidebar class names based upon custom api specification criteria. This is a code change to implement #858.

This code allows you to use the customProps option within the sidebarOptions to specify custom spec criteria to enable class names.

Where the key is the class name to add and the value is the criteria check which will evaluate to true or false.

{
    "sidebarOptions": {
        "groupPathsBy": "tag",
        "categoryLinkSource": "tag",
        "customProps": {
            "additionalClassChecks": {
                "menu__list-item--experimental": "!!item.api.parameters?.find(header => header.name === 'X-SailPoint-Experimental')"
            }
        }
    }
}

Feel free to change the names of variables or config items.

Description

Motivation and Context

#858.

How Has This Been Tested?

Tested in my local environment off of the latest main branch of this plugin.

Screenshots (if appropriate)

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist

  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes if appropriate.
  • All new and existing tests passed.

@sserrata
Copy link
Member

Hi @tyler-mairose-sp, sorry for the delay on getting this PR reviewed/merged. As stated in a separate thread, my primary concern is that this pattern could allow users to inject/execute arbitrary code, which may pose a security risk.

Up to now, our plugin has provided limited support for some vendor extensions like x-codeSamples, x-logo, etc., many of which were contributed/established by the Redocly team.

What if we explore first-class support for vendor extensions specific to our plugin and Docusaurus, e.g. x-sidebar-classname?

@robbieaverill
Copy link
Contributor

I agree with the concern around potential code injection. I would also like to be able to support the same use case as OP.

@robbieaverill
Copy link
Contributor

I've proposed an alternative solution for this problem here: #963

@sserrata
Copy link
Member

Feature addressed in #963

@sserrata sserrata closed this Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants