Skip to content

Commit

Permalink
Updt grid spacing on latest posts
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyPlanden committed Nov 18, 2023
1 parent 316cb1d commit 979063d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 32 deletions.
18 changes: 11 additions & 7 deletions custom/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from mkdocs.plugins import BasePlugin
import re

class MyCustom(BasePlugin):

class MyCustom(BasePlugin):
def on_nav(self, nav, config, files):
self.nav = nav

Expand All @@ -11,13 +11,17 @@ def on_nav(self, nav, config, files):
page.read_source(config)

def recent_pages():
#import ipdb; ipdb.set_trace()
return [page for page in self.nav.pages if page.parent \
and re.match(r'\d{4}', page.parent.title) \
and 'image' in page.meta]
# import ipdb; ipdb.set_trace()
return [
page
for page in self.nav.pages
if page.parent
and re.match(r"\d{4}", page.parent.title)
and "image" in page.meta
]

setattr(nav, 'recent_pages', recent_pages)
setattr(nav, "recent_pages", recent_pages)
return nav

def on_page_context(self, context, page, config, nav):
return context
return context
Binary file modified custom/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
40 changes: 27 additions & 13 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,38 @@
title: Latest Posts
timetoread: False
---

<style>
.grid-item {
border: 2px solid #eee;
padding: 2em;
display: inline-block;
width: 18em;
height: 20em;
vertical-align: middle;
border: 2px solid #eee;
padding: 1em;
display: inline-block;
width: 18em;
height: 20em;
vertical-align: middle;
margin-bottom: 0.5em;
}

.grid-item .content {
display: flex;
flex-direction: column;
justify-content: center;
height: 100%;
}
</style>

<div class="grid">

{% for page in navigation.recent_pages() %}
<div class="grid-item">
<a href="{{ page.url }}">
<figure >
<img src="{{ page.meta.image }}" width="240" loading="lazy"/>
<figcaption>{{page.title}}</figcaption>
</figure>
</a>
<div class="content">
<a href="{{ page.url }}">
<figure>
<img src="{{ page.meta.image }}" width="240" loading="lazy"/>
<figcaption>{{page.title}}</figcaption>
</figure>
</a>
</div>
</div>
{% endfor %}
{% endfor %}
</div>
23 changes: 11 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from distutils.core import setup

setup(
name='mkdocs-custom',
version='0.0.1',
author='Scott Pierce',
author_email='[email protected]',
packages=['custom'],
description='Local custom plugin',
install_requires=['mkdocs', 'jinja2'],

name="mkdocs-custom",
version="0.0.1",
author="Scott Pierce",
author_email="[email protected]",
packages=["custom"],
description="Local custom plugin",
install_requires=["mkdocs", "jinja2"],
entry_points={
'mkdocs.plugins': [
'custom = custom:MyCustom',
"mkdocs.plugins": [
"custom = custom:MyCustom",
]
}
)
},
)

0 comments on commit 979063d

Please sign in to comment.