Skip to content

Commit

Permalink
Merge pull request #32 from liang2kl/dev
Browse files Browse the repository at this point in the history
Support full content display
  • Loading branch information
liang2kl committed Jun 20, 2022
2 parents 2faabcf + 02e97da commit b4b1118
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions mkdocs_blogging_plugin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class BloggingConfig:
show_total: bool
template: str
theme: dict
full_content: bool

def __init__(self, config: dict):
self.dirs = config.get("dirs", [])
Expand All @@ -15,3 +16,4 @@ def __init__(self, config: dict):
self.show_total = config.get("show_total", True)
self.template = config.get("template")
self.theme = config.get("theme")
self.full_content = config.get("full_content", False)
4 changes: 3 additions & 1 deletion mkdocs_blogging_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def get_config_scheme():
("show_total", config_options.Type(bool, default=c.show_total)),
("template", config_options.Type(str, default=c.template)),
("theme", config_options.Type(dict, default=c.theme)),
("full_content", config_options.Type(bool, default=c.full_content)),

# Global-only configurations
("meta_time_format", config_options.Type(str, default=None)),
Expand Down Expand Up @@ -321,7 +322,8 @@ def generate_html(self, category) -> str:
paging=config.paging, is_revision=config.sort["by"] == "revision",
show_total=config.show_total, theme_options=theme_options,
index_url=self.tags_index_url, show_tags="tags" in self.features,
mkdocs_context=self.mkdocs_template_context
mkdocs_context=self.mkdocs_template_context,
full_content=config.full_content,
)

def with_timestamp(self, page, by_revision):
Expand Down
4 changes: 3 additions & 1 deletion mkdocs_blogging_plugin/templates/blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ <h3 class="blog-post-title">
{% endif %}

{% set description = "" %}
{% if pg.meta.description %}
{% if full_content %}
{% set description = pg.content|safe %}
{% elif pg.meta.description %}
{% set description = pg.meta.description|truncate %}
{% endif %}

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name="mkdocs-blogging-plugin",
version="2.0.1",
version="2.1",
description="Mkdocs plugin that generates a blog index page sorted by creation date.",
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
Expand Down
2 changes: 2 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def setUpClass(cls):
},
"paging": False,
"show_total": False,
"full_content": True,
}

cls.config["categories"] = [
Expand All @@ -33,6 +34,7 @@ def setUpClass(cls):
},
"paging": True,
"show_total": True,
"full_content": False,
},
{
"name": "c2",
Expand Down

0 comments on commit b4b1118

Please sign in to comment.