Skip to content
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

[insider] blog post plugin does not include templates #4345

Closed
5 tasks done
vwxyzjn opened this issue Sep 12, 2022 · 3 comments
Closed
5 tasks done

[insider] blog post plugin does not include templates #4345

vwxyzjn opened this issue Sep 12, 2022 · 3 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@vwxyzjn
Copy link

vwxyzjn commented Sep 12, 2022

Contribution guidelines

I've found a bug and checked that ...

  • ... the problem doesn't occur with the mkdocs or readthedocs themes
  • ... the problem persists when all overrides are removed, i.e. custom_dir, extra_javascript and extra_css
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

I was trying to use the blog plugin and set up the directory according to https://squidfunk.github.io/mkdocs-material/blog/2022/09/12/blog-support-just-landed/, but mkdocs serve error out

.
├── docs
│   ├── index.md
│   └── posts
│       └── hello-world.md
└── mkdocs.yml

Expected behaviour

The blog post example should work.

Actual behaviour

When running the insider, I got the following error:

  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/mkdocs/__main__.py", line 181, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 63, in serve
    config = builder()
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 58, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/mkdocs/commands/build.py", line 282, in build
    files = config['plugins'].run_event('files', files, config=config)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/mkdocs/plugins.py", line 102, in run_event
    result = method(item, **kwargs)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/material/plugins/blog/plugin.py", line 270, in on_files
    data = self._generate_files_for_archive(config, files)
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/material/plugins/blog/plugin.py", line 552, in _generate_files_for_archive
    self._generate_file(path, "blog-archive", name),
  File "/home/costa/.cache/pypoetry/virtualenvs/cleanrl-ghSZGHE3-py3.9/lib/python3.9/site-packages/material/plugins/blog/plugin.py", line 673, in _generate_file
    os.path.join(
  File "/home/costa/.pyenv/versions/3.9.5/lib/python3.9/posixpath.py", line 76, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

The relevant code is

        if "template" not in page.meta:
            page.meta["template"] = os.path.normpath(
                os.path.join(
                    self.config.get("blog_custom_dir", "."),
                    "blog-post.html"
                )
            )

so it looks like the insider is not finding blog_custom_dir's blog-post.html properly.

Steps to reproduce

Follow https://squidfunk.github.io/mkdocs-material/blog/2022/09/12/blog-support-just-landed/.

Package versions

  • Python: python --version: Python 3.9.5
  • MkDocs: mkdocs --version: mkdocs, version 1.3.1
  • Material: pip show mkdocs-material | grep -E ^Version: this command does not work. I installed via pip install git+https://${GH_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git.

Configuration

site_name: My Blog
theme:
  name: material
  features:
    - navigation.sections
plugins:
  - blog:
      blog_dir: . 
  - search
  - tags
nav:
  - index.md

System information

  • Operating system: linux
  • Browser: chome
@squidfunk
Copy link
Owner

Thanks for reporting! blog_custom_dir is an internal feature that is not meant to be used by the user. It's also why it's not documented. However, it should not error. I'll look into it right away.

@squidfunk squidfunk added the bug Issue reports a bug label Sep 12, 2022
@squidfunk
Copy link
Owner

Fixed in squidfunk/mkdocs-material-insiders@21578b300. The blog_custom_dir options is just for internal use, in order to make theme extension work for Material for MkDocs itself. The problem is that the theme is using the custom_dir setting, so overriding is not possible as advertised on the documentation. This only matters to maintainers, so no worry.

It should not be necessary to set blog_custom_dir anymore.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Sep 12, 2022
@squidfunk
Copy link
Owner

The fix was released as part of 8.4.4-insiders-4.23.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants