Skip to content

Commit f81c8bc

Browse files
committed
Fix Article bundle review findings
1 parent 6deaa4b commit f81c8bc

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

.github/workflows/add-article.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,20 @@ jobs:
8888
front = yaml.safe_dump(fm, default_flow_style=False, allow_unicode=True, sort_keys=False)
8989
document = '---\n' + front + '---\n\n' + content + '\n'
9090
91-
filepath = f"content/articles/{today.strftime('%Y')}/{today.strftime('%m')}/{slug}/index.md"
91+
year = today.strftime('%Y')
92+
month = today.strftime('%m')
93+
year_index = f'content/articles/{year}/_index.md'
94+
month_index = f'content/articles/{year}/{month}/_index.md'
95+
filepath = f'content/articles/{year}/{month}/{slug}/index.md'
96+
if os.path.exists(filepath):
97+
raise SystemExit(f'Article bundle already exists: {filepath}')
9298
os.makedirs(os.path.dirname(filepath), exist_ok=True)
99+
if not os.path.exists(year_index):
100+
with open(year_index, 'w', encoding='utf-8') as f:
101+
f.write(f'---\ntitle: "Articles from {year}"\ndescription: "PowerShell.org Articles published in {year}."\n---\n')
102+
if not os.path.exists(month_index):
103+
with open(month_index, 'w', encoding='utf-8') as f:
104+
f.write(f'---\ntitle: "Articles from {today.strftime("%B %Y")}"\ndescription: "PowerShell.org Articles published in {today.strftime("%B %Y")}."\n---\n')
93105
with open(filepath, 'w', encoding='utf-8') as f:
94106
f.write(document)
95107
@@ -98,6 +110,8 @@ jobs:
98110
out.write(f'slug={slug}\n')
99111
out.write(f'filepath={filepath}\n')
100112
out.write(f'article_title={title}\n')
113+
out.write(f'year_index={year_index}\n')
114+
out.write(f'month_index={month_index}\n')
101115
102116
print(f'Created {filepath}')
103117
PYEOF
@@ -108,14 +122,16 @@ jobs:
108122
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109123
SLUG: ${{ steps.parse.outputs.slug }}
110124
FILEPATH: ${{ steps.parse.outputs.filepath }}
125+
YEAR_INDEX: ${{ steps.parse.outputs.year_index }}
126+
MONTH_INDEX: ${{ steps.parse.outputs.month_index }}
111127
ARTICLE_TITLE: ${{ steps.parse.outputs.article_title }}
112128
ISSUE_NUMBER: ${{ github.event.issue.number }}
113129
run: |
114130
BRANCH="article/issue-${ISSUE_NUMBER}-${SLUG}"
115131
git config user.name "github-actions[bot]"
116132
git config user.email "github-actions[bot]@users.noreply.github.com"
117133
git checkout -b "$BRANCH"
118-
git add "$FILEPATH"
134+
git add "$FILEPATH" "$YEAR_INDEX" "$MONTH_INDEX"
119135
git commit -m "Add article: ${ARTICLE_TITLE} (closes #${ISSUE_NUMBER})"
120136
git push origin "$BRANCH"
121137
gh pr create \

scripts/validate-article-bundles.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ function stringValue(metadata, field) {
2626
}
2727

2828
function listValues(metadata, field) {
29-
const values = metadata.match(new RegExp(`^${field}:\\s*\\r?\\n((?:\\s{2}- .+\\r?\\n?)*)`, 'm'))?.[1] ?? '';
30-
return [...values.matchAll(/^\s{2}-\s+(.+)$/gm)].map((value) => value[1].trim());
29+
const values = metadata.match(new RegExp(`^${field}:\\s*\\r?\\n((?:\\s*- .+\\r?\\n?)*)`, 'm'))?.[1] ?? '';
30+
return [...values.matchAll(/^\s*-\s+(.+)$/gm)].map((value) => value[1].trim());
3131
}
3232

3333
function outputFile(route) { return join(outputRoot, route.replace(/^\//, ''), 'index.html'); }

themes/powershell-community/layouts/_default/list.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ <h1 class="text-4xl lg:text-5xl font-bold mb-2">
3131

3232
<!-- Content Grid -->
3333
<div class="grid gap-6" id="content-container">
34-
{{ $paginator := .Paginate .RegularPagesRecursive }}
34+
{{ $pages := .Pages }}
35+
{{ if eq .Section "articles" }}{{ $pages = .RegularPagesRecursive }}{{ end }}
36+
{{ $paginator := .Paginate $pages }}
3537
{{ range $paginator.Pages }}
3638
<article class="content-item bg-white rounded-xl shadow-md hover:shadow-lg transition-shadow duration-300 overflow-hidden"
3739
data-title="{{ .Title | lower }}"

0 commit comments

Comments
 (0)