Skip to content

Autogenerated entries: allow image override per entry #7844

Closed as not planned

Description

@ArthurFlag

Have you read the Contributing Guidelines on issues?

Description

In the current state, Docusaurus' autogenerated entries generates tiles looking like this:

Screenshot 2022-07-28 at 16 13 45

Auto-generating entries is a great feature, and in my case, I'd like to use it to get scalable docs, such as listing many partners that my company integrates with.

For this, I would suggest to add the ability to customize the image that we add to the tile. Currently it's either the file or folder icon.

For example, adding this to the sidebar to specify a new image:

  {
          type: 'category',
          label: 'Essentials',
          link: {
            type: 'generated-index',
            title: 'Essentials',
            image: 'somelogopath.png'  <------- new
            description: 'my description',
            slug: 'dev/tutorials/essentials',
          },
          items: [
            'some link',
}

Or when generating tiles from a doc page with:

<DocCardList items={useCurrentSidebarCategory().items}/>

We could perhaps define the image in each entry in the sidebar.js file as well, using longhand notation:

   {
              type: 'category',
              label: 'My page',
              link: {
                type: 'doc', 
                id: 'dev/...', <------- contains the DocCardList component
              },
              items: [
               {
                  type: 'doc',
                  id: 'myDoc',
                  image: 'somelogopath.png'  <------- new
                },
              ],
            }

Has this been requested on Canny?

No response

Motivation

I need this feature for scalability reasons so this feature will happen either on my own repo, but it should ideally be a core feature as it might help other users. I can possibly get a developer to submit a PR to your repo if you can share some pointers on how to do this 'the right way'.

API design

No response

Have you tried building it?

No response

Self-service

  • I'd be willing to contribute this feature to Docusaurus myself.

Activity

  1. added
    feature
    status: needs triage
    on Jul 28, 2022
  2. Josh-Cena commented on Jul 28, 2022

    @Josh-Cena
    Collaborator

    By "image", you mean the "icon"?

    You can already do so by swizzling and passing the source through customProps. It's very, very hard to design a generalizable API in this case, because most icons aren't images—they are either SVGs, React components, font awesome, or emojis.

  3. ArthurFlag commented on Jul 28, 2022

    @ArthurFlag
    Author

    that's what i meant. yes. Ok brilliant, i'll take a look at this, thanks Josh.

  4. added
    closed: wontfix
    and removed
    status: needs triage
    on Jul 29, 2022
  5. smileypop commented on Sep 20, 2023

    @smileypop

    By "image", you mean the "icon"?

    You can already do so by swizzling and passing the source through customProps. It's very, very hard to design a generalizable API in this case, because most icons aren't images—they are either SVGs, React components, font awesome, or emojis.

    Just saying "swizzle" it doesn't give enough information how to actually do so. Without adding any API changes, it would still be helpful to put some actual code examples in the docs how to achieve custom Link icons on autogenerated category cards.

  6. colinscz commented on Sep 27, 2023

    @colinscz

    For everyone coming here. The component you have to swizzle is the DocCard component. I recommend to swizzle it with --eject in order to not modify too much of the original component.

    That way in case of potential breaking changes (upcoming v3) the diff and migration effort is hopefully rather small and you can compare newer versions to your old code.

    Command used: npm run swizzle @docusaurus/theme-classic DocCard -- --eject

  7. undergroundwires commented on Jun 18, 2024

    @undergroundwires

    Hope that this can be revisted with proper official way rather than having a workaround/hack that leads to this:

    [WARNING] 
    Swizzle action eject is unsafe to perform on DocCard.
    It is more likely to be affected by breaking changes in the future
    
  8. slorber commented on Jun 20, 2024

    @slorber
    Collaborator

    @undergroundwires this is not a workaround/hack, this is the official way

    You can override whatever we provide, we just want to warn you that we might have to refactor things and you'd need to adjust your code accordingly.

    Unsafe might feel a bit too scary but it's perfectly fine to eject it

  9. slorber commented on Sep 4, 2024

    @slorber
    Collaborator

    For anyone interested, I explained how to do this here: #10476 (comment)

    image

  10. bvanelli commented on Oct 23, 2025

    @bvanelli

    I understand that changing this for the arbitrary image case is out of scope, but couldn't the emoji change that @slorber showed be taken as general change? As far as I can tell the original page icon is already an emoji (in this case 📄️), so it could be implemented without much effort. Is there a reasoning against it?

    Here are the docs: https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs#markdown-front-matter

    The extra option could be called icon. The image option already exists and is used for link expansion for social media.

    I would of course be willing to implement the feature and writing the documentation for it, if such feature were to be accepted.

  11. slorber commented on Oct 23, 2025

    @slorber
    Collaborator

    I would be fine if we worked on designing such a feature on a separate issue, leading to an implementation later.

    We could add icon to sidebar items, icon in _category_.json, and sidebar_icon front matter in docs.

    However, wouldn't this be confusing if we could only pass emojis as icons? Also, how do you control what is displayed on the generated index? My intuitive expectation would be that the icon also shows on sidebar items, and not just the generated index. Do we need to create 2 options to decouple the 2?

    As you can see, before implementing anything, we need to research and design what should be done exactly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    closed: wontfixfeature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions