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

blog plugin breaks when some files have datetime and others have date only. #4532

Closed
5 tasks done
ZhiyuanChen opened this issue Oct 23, 2022 · 2 comments
Closed
5 tasks done
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@ZhiyuanChen
Copy link

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

blog plugin breaks when some files have datetime and others have date only.

Expected behaviour

Works

Actual behaviour

Traceback (most recent call last):
  File "/home/codespace/.python/current/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/mkdocs/__main__.py", line 234, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/mkdocs/commands/serve.py", line 82, in serve
    builder(config)
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/mkdocs/commands/serve.py", line 75, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/mkdocs/commands/build.py", line 297, in build
    files = config.plugins.run_event('files', files, config=config)
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/mkdocs/plugins.py", line 517, in run_event
    result = method(item, **kwargs)
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/material/plugins/blog/plugin.py", line 263, in on_files
    self.post_meta_map = dict(sorted(
TypeError: can't compare datetime.datetime to datetime.date

Steps to reproduce

hello.md:

---
date: 2022-01-31
readtime: 15
---

# hello, 
...

world:

---
date: 2022-01-31 00:00:00
readtime: 15
---

# world!
...

Package versions

  • Python: 3.10.4
  • MkDocs: mkdocs, version 1.4.1 from /usr/local/python/3.10.4/lib/python3.10/site-packages/mkdocs (Python 3.10)
  • Material: 8.5.7+insiders.4.26.1

(Though the output of pip show mkdocs-material | grep -E ^Version is as follows:

grep: docs copy: Is a directory
mkdocs.yml:      bib_file: "docs/references.bib"
grep: overrides: Is a directory
requirments.txt:mkdocs
requirments.txt:mkdocs-material
requirments.txt:mkdocs-awesome-pages-plugin
requirments.txt:mkdocs-bibtex
requirments.txt:mkdocs-git-revision-date-localized-plugin
requirments.txt:mkdocs-git-committers-plugin
requirments.txt:mkdocs-rss-plugin
requirments.txt:mkdocs-static-i18n
requirments.txt:mkdocstrings
requirments.txt:mkdocstrings[python]
ERROR: Pipe to stdout was broken
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
BrokenPipeError: [Errno 32] Broken pipe

Configuration

nav:
  - index.md

theme:
  name: material
  custom_dir: overrides
  language: 'zh'
  palette:
    - media: "(prefers-color-scheme: dark)"
      scheme: slate
      primary: blue grey
      accent: teal
      toggle:
        icon: material/brightness-4
        name: Switch to light mode
    - media: "(prefers-color-scheme: light)"
      scheme: default
      primary: blue grey
      accent: teal
      toggle:
        icon: material/brightness-7
        name: Switch to dark mode
  logo: 'assets/images/logo.png'
  favicon: 'assets/images/logo.ico'
  features:
    - announce.dismiss
    - content.code.annotate
    - content.tabs.link
    - content.tooltips
    - header.autohide
    - navigation.expand
    - navigation.indexes
    - navigation.instant
    - navigation.prune
    - navigation.sections
    - navigation.tabs
    - navigation.tabs.sticky
    - navigation.top
    - navigation.tracking
    - search.highlight
    - search.share
    - search.suggest
    - toc.follow
    - toc.integrate
  font: false

extra_javascript: 
  - javascripts/mathjax.js
  - https://polyfill.io/v3/polyfill.min.js?features=es6
  - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
  - javascripts/shortcuts.js

markdown_extensions:
  - abbr
  - admonition
  - attr_list
  - def_list
  - footnotes
  - md_in_html
  - mdx_math
  - meta
  - pymdownx.arithmatex:
      generic: true
  - pymdownx.betterem:
      smart_enable: all
  - pymdownx.caret
  - pymdownx.critic
  - pymdownx.details
  - pymdownx.emoji:
      emoji_index: !!python/name:materialx.emoji.twemoji
      emoji_generator: !!python/name:materialx.emoji.to_svg
  - pymdownx.highlight:
      anchor_linenums: true
      auto_title: true
      linenums: true
  - pymdownx.inlinehilite
  - pymdownx.keys
  - pymdownx.magiclink
  - pymdownx.mark
  - pymdownx.smartsymbols
  - pymdownx.snippets
  - pymdownx.superfences:
      custom_fences:
        - name: mermaid
          class: mermaid
          format: !!python/name:pymdownx.superfences.fence_code_format
  - pymdownx.tabbed:
      alternate_style: true
  - pymdownx.tasklist:
      custom_checkbox: true
  - pymdownx.tilde
  - smarty
  - tables
  - toc:
      permalink: true

plugins:
  - meta
  - blog:
      blog_dir: .
      post_date_format: full
      post_url_format: "{slug}"
  - bibtex:
      bib_file: "docs/references.bib"
      csl_file: "https://raw.githubusercontent.com/citation-style-language/styles/master/ieee.csl"
      cite_inline: true
  # - git-revision-date-localized:
  #     type: iso_datetime
  # - git-committers
  - privacy:
      externals_exclude:
        - cdn.jsdelivr.net/npm/mathjax@3/*
        - giscus.app/*
        - github-readme-stats.vercel.app/*
  - rss:
      match_path: .* 
      date_from_meta:
        as_creation: date
      categories:
        - categories
        - tags
  - search:
      separator: '[\s\u200b\-]'
  - tags

System information

github codespaces

@squidfunk squidfunk added the needs investigation Issue must be investigated by the maintainers label Oct 24, 2022
@squidfunk
Copy link
Owner

Thanks for reporting. Fixed in squidfunk/mkdocs-material-insiders@edd4a7f8e3cc40d8204afde5afceeebf1970acb4.

@squidfunk squidfunk added bug Issue reports a bug resolved Issue is resolved, yet unreleased if open and removed needs investigation Issue must be investigated by the maintainers labels Oct 25, 2022
@squidfunk
Copy link
Owner

Released as part of 8.5.8+insiders-4.26.2.

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