8000 Social plugin unable to load logo icon from custom icon set · Issue #4920 · squidfunk/mkdocs-material · GitHub
[go: up one dir, main page]

Skip to content

Social plugin unable to load logo icon from custom icon set #4920

@bzoel

Description

@bzoel

Context

No response

Bug description

When mkdocs-material is configured with a custom icon set and the social plugin, the social plugin looks in the wrong place for the icon.

mkdocs.yml

site_name: My Docs
site_url: https://localhost:8000
theme:
  name: material
  custom_dir: overrides
  icon:
    logo: iconset1/myicon
plugins:
  - search
  - social
% mkdocs build
INFO     -  Cleaning site directory
INFO     -  Building documentation to directory: /Users/bz/dev/mkdocs-test/site
Traceback (most recent call last):
  File "/Users/bz/dev/mkdocs-test/venv/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/mkdocs/__main__.py", line 250, in build_command
    build.build(cfg, dirty=not clean)
  File "/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/mkdocs/commands/build.py", line 332, in build
    config.plugins.run_event('post_build', config=config)
  File "/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/mkdocs/plugins.py", line 522, in run_event
    result = method(**kwargs)
  File "/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/material/plugins/social/plugin.py", line 173, in on_post_build
    promise.result()
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    return self.__get_result()
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/material/plugins/social/plugin.py", line 180, in _cache_image
    image = render_function()
  File "/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/material/plugins/social/plugin.py", line 160, in <lambda>
    render_function = lambda: self._render_card(site_name, title, description)
  File "/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/material/plugins/social/plugin.py", line 195, in _render_card
    self._resized_logo_promise.result(),
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    return self.__get_result()
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/material/plugins/social/plugin.py", line 334, in _load_resized_logo
    logo = self._load_logo(config)
  File "/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/material/plugins/social/plugin.py", line 368, in _load_logo
    return self._load_logo_svg(path, self.color["text"])
  File "/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/material/plugins/social/plugin.py", line 373, in _load_logo_svg
    data = open(path).read()
FileNotFoundError: [Errno 2] No such file or directory: '/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/material/.icons/iconset1/myicon.svg'

Related links

Similar to Issue 4812, except in my case, a custom icon set is being used instead of a custom image.

Reproduction

Note: I have commented out the custom_dir in the reproduction so that the info plugin would run. This customization is mentioned in the logo and icons documentation that I referenced.
example.zip

Steps to reproduce

  1. Uncomment theme.custom_dir in mkdocs.yml
  2. mkdocs build or mkdocs serve
  3. Error from the social plugin looking in the material theme folder instead of the override folder FileNotFoundError: [Errno 2] No such file or directory: '/Users/bz/dev/mkdocs-test/venv/lib/python3.10/site-packages/material/.icons/iconset1/myicon.svg'

Browser

Chrome

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0