Skip to content

How to reuse icons from the default theme? #1978

@DiFuks

Description

@DiFuks

Hello! I am the author of the typedoc-theme-hierarchy library. I have a problem with icons
Prior to version 0.23.2, I simply set the css class tsd-kind-icon for links and subItem.cssClasses for list items:

<li class={subItem.cssClasses}>
  <a
    class='tsd-kind-icon'
    href={urlTo(subItem)}
  >
    {subItem.name}
  </a>
</li>

And the icons appeared. But since version 0.23.2 icons in the default theme are set in a different way

export const icons: Record<ReflectionKind, () => JSX.Element> & UtilityIcons = {

I tried to import:

import { icons } from 'typedoc/dist/lib/output/themes/default/partials/icon';

And change the code to the following:

<li>
    <a href={urlTo(subItem)}>
      {icons[subItem.kind]}
      {subItem.name}
    </a>
</li>

Now, when I try to run the typedoc command, I get the following error:

error The plugin typedoc-theme-hierarchy could not be loaded.
error Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/lib/output/themes/default/partials/icon' is not defined by "exports" in /Users/difuks/PhpstormProjects/typedoc-test/node_modules/typedoc/package.json

As I understand it, this is due to the definition of the exports field in package.json

https://github.com/TypeStrong/typedoc/blob/master/package.json#L7

But I still could not correctly import the variable icons

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion about functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions