Skip to content

Commit

Permalink
Add md-typeset wrapper (#52)
Browse files Browse the repository at this point in the history
Add `md-typeset` wrapper on blog posts to support other themes
  • Loading branch information
liang2kl committed Jun 8, 2023
1 parent e97fb1f commit 49098d2
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 44 deletions.
6 changes: 4 additions & 2 deletions mkdocs_blogging_plugin/templates/blog-tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
{% from "blog-tags-render.html" import get_tags_style %}
{% endif %}

{% call render_tags(tags, index_url) -%}
{% endcall %}
<div class="md-typeset">
{% call render_tags(tags, index_url) -%}
{% endcall %}
</div>

{% call get_tags_style() -%}
{% endcall %}
86 changes: 44 additions & 42 deletions mkdocs_blogging_plugin/templates/blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,50 +119,52 @@ <h3 class="blog-post-title">
{%- endmacro %}
{% endif %}

<div class="pages">
{% for page_idx in range(0, page_num) %}
{% set pg_group = pages[page_idx*page_size:(page_idx + 1)*page_size] %}
<div class="page" id="page{{ page_idx + 1 }}">

{% for pg in pg_group %}
{# Setting variables. #}
{% set url = pg.canonical_url %}
{% set title = pg.title %}
{% if pg.meta and pg.meta.title_full %}
{% set title = pg.meta.title_full %}
{% endif %}

{% set description = "" %}
{% if full_content %}
{% set description = pg.content|safe %}
{% elif pg.meta.description %}
{% set description = pg.meta.description|truncate %}
{% endif %}
<div class = "md-typeset">
<div class="pages">
{% for page_idx in range(0, page_num) %}
{% set pg_group = pages[page_idx*page_size:(page_idx + 1)*page_size] %}
<div class="page" id="page{{ page_idx + 1 }}">

{% for pg in pg_group %}
{# Setting variables. #}
{% set url = pg.canonical_url %}
{% set title = pg.title %}
{% if pg.meta and pg.meta.title_full %}
{% set title = pg.meta.title_full %}
{% endif %}

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

{% set time = "" %}
{% if pg.meta and pg.meta["localized-time"] %}
{% set time = pg.meta["localized-time"] %}
{% endif %}

{% call render_blog(title, description, time, url, pg) %}
{% endcall %}
{% endfor %}
</div>
{% endfor %}
</div>

{% set time = "" %}
{% if pg.meta and pg.meta["localized-time"] %}
{% set time = pg.meta["localized-time"] %}
<div class="blog-center {{'blog-hidden' if page_num == 1 else '' }}">
<div class="blog-pagination " id="blog-pagination">
{% for num in range(page_num) %}
{% if num == 0 %}
{% set link = "" %}
{% else %}
{% set link = "#blog-p" + (num + 1)|string %}
{% endif %}

{% call render_blog(title, description, time, url, pg) %}
{% endcall %}
<a class="page-number" href="{{ link }}">{{ num + 1 }}</a>
{% endfor %}
</div>
{% endfor %}
</div>

<div class="blog-center {{'blog-hidden' if page_num == 1 else '' }}">
<div class="blog-pagination " id="blog-pagination">
{% for num in range(page_num) %}
{% if num == 0 %}
{% set link = "" %}
{% else %}
{% set link = "#blog-p" + (num + 1)|string %}
{% endif %}
<a class="page-number" href="{{ link }}">{{ num + 1 }}</a>
{% endfor %}
{% if show_total %}
<div>Total <b>{{ pages|count }}</b> posts.</div>
{% endif %}
</div>
{% if show_total %}
<div>Total <b>{{ pages|count }}</b> posts.</div>
{% endif %}
</div>
</div>

0 comments on commit 49098d2

Please sign in to comment.