diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index ff3d3cfe1..2ab8e87ed 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -271,8 +271,6 @@ class BlogPlugin(BasePlugin[BlogConfig]): raise PluginError( f"Couldn't find '{separator}' in post '{path}' in '{docs}'" ) - else: - page.markdown += f"\n\n{separator}" # Create excerpt for post and inherit authors and categories - excerpts # can contain a subset of the authors and categories of the post diff --git a/material/plugins/blog/structure/__init__.py b/material/plugins/blog/structure/__init__.py index 12a383b33..255a26934 100644 --- a/material/plugins/blog/structure/__init__.py +++ b/material/plugins/blog/structure/__init__.py @@ -156,6 +156,10 @@ class Excerpt(Page): self.authors: list[Author] = [] self.categories: list[Category] = [] + # Initialize content after separator - allow template authors to render + # posts inline or to provide a link to the post's page + self.more = None + # Initialize parser - note that we need to patch the configuration, # more specifically the table of contents extension config = _patch(config) @@ -200,7 +204,9 @@ class Excerpt(Page): # Convert Markdown to HTML and extract excerpt self.content = self.md.convert(self.markdown) - self.content, *_ = self.content.split(separator, 1) + self.content, *more = self.content.split(separator, 1) + if more: + self.more = more[0] # Extract table of contents and reset post URL - if we wouldn't reset # the excerpt URL, linking to the excerpt from the view would not work diff --git a/material/templates/partials/post.html b/material/templates/partials/post.html index 08f3c8f1d..772a0a8c1 100644 --- a/material/templates/partials/post.html +++ b/material/templates/partials/post.html @@ -51,10 +51,12 @@
{{ post.content }} - + {% if post.more %} + + {% endif %}
diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index ff3d3cfe1..2ab8e87ed 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -271,8 +271,6 @@ class BlogPlugin(BasePlugin[BlogConfig]): raise PluginError( f"Couldn't find '{separator}' in post '{path}' in '{docs}'" ) - else: - page.markdown += f"\n\n{separator}" # Create excerpt for post and inherit authors and categories - excerpts # can contain a subset of the authors and categories of the post diff --git a/src/plugins/blog/structure/__init__.py b/src/plugins/blog/structure/__init__.py index 12a383b33..255a26934 100644 --- a/src/plugins/blog/structure/__init__.py +++ b/src/plugins/blog/structure/__init__.py @@ -156,6 +156,10 @@ class Excerpt(Page): self.authors: list[Author] = [] self.categories: list[Category] = [] + # Initialize content after separator - allow template authors to render + # posts inline or to provide a link to the post's page + self.more = None + # Initialize parser - note that we need to patch the configuration, # more specifically the table of contents extension config = _patch(config) @@ -200,7 +204,9 @@ class Excerpt(Page): # Convert Markdown to HTML and extract excerpt self.content = self.md.convert(self.markdown) - self.content, *_ = self.content.split(separator, 1) + self.content, *more = self.content.split(separator, 1) + if more: + self.more = more[0] # Extract table of contents and reset post URL - if we wouldn't reset # the excerpt URL, linking to the excerpt from the view would not work diff --git a/src/templates/partials/post.html b/src/templates/partials/post.html index 2d5451146..20e7141a6 100644 --- a/src/templates/partials/post.html +++ b/src/templates/partials/post.html @@ -90,10 +90,12 @@ {{ post.content }} - + {% if post.more %} + + {% endif %}