Skip to content

Commit 0e0013f

Browse files
authored
Merge pull request #563 from BlackPythonDevs/556-auto-generate-post-descriptions
556 auto generate post descriptions
2 parents 98aeeae + 667497a commit 0e0013f

31 files changed

+313
-71
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,11 @@ repos:
3232
rev: 23.9.1
3333
hooks:
3434
- id: black
35+
- repo: local
36+
hooks:
37+
- id: check-for-layout
38+
name: check-for-layout
39+
files: _posts/.*.md
40+
entry: python update_layout.py
41+
language: python
42+
additional_dependencies: [typer, python-frontmatter, typing-extensions]

MAINTAINERS.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ First off, thank you for considering contributing to Black Python Devs website.
1414
- [Translations](#translations)
1515
- [Styling](#styling)
1616
- [Adding New Pages](#adding-new-pages)
17+
- Post Validation
1718

1819
# Before You Get Started
1920

@@ -203,6 +204,34 @@ ROUTES = [
203204

204205
- Make sure your new page renders correctly and all links work as expected.
205206

207+
## Layout Validation
208+
209+
### Automatic Layout Updates
210+
211+
To ensure consistency across all blog posts, we've implemented automatic layout validation and updating functionality. This helps maintain proper frontmatter configuration for all Markdown files in the `_posts` directory.
212+
213+
### Tools and Features
214+
215+
#### `update_layout.py` CLI Tool
216+
217+
- Checks and applies missing layout fields to post files
218+
- Can process multiple posts simultaneously
219+
- Usage:
220+
```bash
221+
python update_layout.py fix|check path/to/post1.md [path/to/post2.md ...]
222+
```
223+
224+
#### Pre-commit Hook
225+
226+
We've implemented a custom pre-commit hook that automatically runs the `update_layout.py` update check on any `.md` files in the `_posts` directory that are being committed. The hook will:
227+
228+
- Run automatically before each commit
229+
- Check all modified `.md` files in the `_posts` directory
230+
- Apply the necessary layout field if missing
231+
- Fail the commit initially but fix the issue, allowing you to commit again
232+
233+
For manual layout checks and updates, you can always run the `update_layout.py` tool directly.
234+
206235
---
207236

208237
Remember, when in doubt, don't hesitate to ask for help in our Discord community or in a GitHub issue!

_includes/latest-posts.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ <h2 class="post-list-heading">{{ page.list_title }}</h2>
77
<h3>
88
<a class="" href="{{ post.url | relative_url }}"> {{ post.title | escape }} </a>
99
</h3>
10-
<span class="post-meta">{{ post.date | date: date_format }}</span>
11-
{%- if site.show_excerpts -%} {{ post.excerpt }} {%- endif -%}
10+
<p>{{ post.date | date: date_format }}</p>
11+
{%- if site.show_excerpts -%}
12+
<p class="post-description" style="margin-bottom: 2rem">{{ post.description}}</p>
13+
{%- endif -%}
1214
</div>
1315
{%- assign count = count | plus:1 -%} {%- endif -%} {%- endfor -%}
1416
</article>

_includes/posts.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ <h3>
2020
</h3>
2121
<span class="post-meta">{{ post.date | date: date_format }}</span>
2222
{%- if site.show_excerpts -%}
23-
{{ post.excerpt }}
24-
{%- endif -%}
23+
<p class="post-description">
24+
{{ post.description }}
25+
</p>
26+
{%- endif -%}
2527
</div>
2628
{%- assign count = count | plus:1 -%}
2729
{%- endfor -%}

_layouts/default.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1" />
6-
<meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}" />
6+
<meta name="description" content="{% if page.description%}{{ page.description | escape }}{% else %}{{ site.description }}{% endif %}" />
77
<title>{% if page.title %}{{ site.title }} | {{ page.title }}{% else %}{{ site.title }}{% endif %}</title>
88
<link rel="stylesheet" href="{{ '/assets/css/style.css' | relative_url }}" />
99
<link rel="stylesheet" href="{{ '/assets/css/pico.min.css' | relative_url }}" />

_posts/2023-10-20-djangoconus.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
---
2-
layout: post
3-
lang: en
4-
title: "DjangoCon US 2023"
52
date: 2023-10-20
3+
description: Join us for a behind-the-scenes look at DjangoCon US 2023, where diversity
4+
and inclusion came together to shape a powerful community of Python developers.
5+
lang: en
6+
layout: post
7+
title: DjangoCon US 2023
68
---
79

810
In Durham, North Carolina, approximately 300 Django developers gathered from all over the world for [DjangoCon US](https://2023.djangocon.us/). This event showcased the knowledge of the community and celebrated its cultural diversity and the diversity of its hosting city. The event was located at the Marriot Convention Center, in the heart of the city. There were many resturants and smaller attractions.

_posts/2023-11-11-what-is-the-us-conference-city-diversity-metric.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
---
2-
title: "What is the US Conference City Diversity Metric"
3-
layout: post
4-
lang: en
5-
date: 2023-11-11
62
author: Jay Miller
3+
date: 2023-11-11
4+
description: Discover how the US Conference Diversity Metric can inform your event's
5+
location and create a more inclusive experience for attendees, with expert analysis
6+
from Jay Miller.
7+
lang: en
8+
layout: post
9+
title: What is the US Conference City Diversity Metric
710
---
811

912
In 2022 at DjangoCon I took a look at the location of all of the PyCon US locations and their makeup by race. I highlighted that in the first 10 years of PyCon's existence, 9 of those 10 events were in culturally diverse cities like Atlanta, Washington DC and Chicago. The second half was during Python's boom and the need for larger venues started pushing conferences to more affordable areas with large international airports. These were places like Salt Lake City, Portland, and Montreal.

_posts/2023-11-13-black-python-devs-represent-in-dsf-elections.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
---
2-
title: "Black Python Devs Represent in DSF Elections"
3-
date: 2023-11-13
42
author: Jay Miller
3+
date: 2023-11-13
4+
description: Find out how the growing presence of Black Python Developers is shaping
5+
the future of diversity in the tech industry through the DSF Elections.
56
lang: en
67
layout: post
8+
title: Black Python Devs Represent in DSF Elections
79
---
810

911
The DSF Board Elections have opened and voting is available for DSF members now until 27 November 2023 (Anywhere on Earth).

_posts/2023-12-14-dawn-wages-sarah-abderemane-and-djangonaut-space-awarded-the-malcolm-tredinnick-memorial-prize.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
---
2-
title: "Dawn Wages, Sarah Abderemane and Djangonaut Space Awarded the Malcolm Tredinnick Memorial Prize"
3-
date: 2023-12-14
42
author: Jay Miller
3+
date: 2023-12-14
4+
description: Discover how the innovative team at Djangonaut Space is making a lasting
5+
impact on the Django community with sustainable initiatives and groundbreaking projects.
56
lang: en
67
layout: post
8+
title: Dawn Wages, Sarah Abderemane and Djangonaut Space Awarded the Malcolm Tredinnick
9+
Memorial Prize
710
---
811

912
Each year the _Django Software Foundation_, selects a person or group that exemplifies the outstanding service to community as shown by the award's namesake.

_posts/2023-12-14-sarah-abderemane-selected-to-the-django-software-foundation-board.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
---
2-
title: "Sarah Abderemane Selected to the Django Software Foundation Board of Directors"
3-
date: 2023-12-14
42
author: Jay Miller
3+
date: 2023-12-14
4+
description: Discover how Sarah Abderemane's selection to the Django Software Foundation
5+
Board of Directors is a significant milestone for the thriving Black Python Devs
6+
community.
57
lang: en
68
layout: post
9+
title: Sarah Abderemane Selected to the Django Software Foundation Board of Directors
710
---
811

912
This year Black Python Devs were strongly represented with [41% of the folks running](https://blackpythondevs.github.io/2023-11-13-black-python-devs-represent-in-dsf-elections/) belonging to the community.

0 commit comments

Comments
 (0)