Skip to content

Commit f332d04

Browse files
authored
Added Posts (#47)
1 parent f06c053 commit f332d04

5 files changed

Lines changed: 156 additions & 18 deletions

File tree

.github/workflows/build-and-deploy.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,29 +198,37 @@ jobs:
198198
return $versionParts
199199
}
200200
201-
[string] $documentationDirectoryPath = if ('${{ github.event_name }}' -ieq 'release' -or '${{ github.ref_name }}' -ieq 'dev') { '${{ github.ref_name }}' } else { 'dev/${{ github.ref_name }}' }
202-
dotnet run `
203-
--project CodeMap.Documentation `
204-
--configuration Release `
205-
--no-build `
206-
-- `
207-
-OutputFilePath "./docs/$documentationDirectoryPath/index.html"
208-
209201
New-Item `
210202
-Type Directory `
211203
-Name docs `
212-
-ErrorAction SilentlyContinue
204+
-ErrorAction SilentlyContinue `
205+
| Out-Null
213206
New-Item `
214207
-Type Directory `
215208
-Name _data `
216209
-Path docs `
217-
-ErrorAction SilentlyContinue
210+
-ErrorAction SilentlyContinue `
211+
| Out-Null
212+
213+
[string] $documentationDirectoryPath = if ('${{ github.event_name }}' -ieq 'release' -or '${{ github.ref_name }}' -ieq 'dev') { '${{ github.ref_name }}' } else { 'dev/${{ github.ref_name }}' }
214+
dotnet run `
215+
--project CodeMap.Documentation `
216+
--configuration Release `
217+
--no-build `
218+
-- `
219+
-OutputFilePath "./docs/$documentationDirectoryPath/index.html"
218220
219221
if (Test-Path 'CodeMap.Documentation/GitHub Pages') {
220222
Copy-Item `
221223
-Path 'CodeMap.Documentation/GitHub Pages/*' `
222224
-Destination './docs' `
223225
-Recurse
226+
227+
if (('${{ github.ref_name }}' -ine 'dev') -and (Test-Path './docs/_posts')) {
228+
Remove-Item `
229+
-Path './docs/_posts' `
230+
-Recurse
231+
}
224232
}
225233
226234
Sort-SemVerDescending (
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
paginate: 10
2+
paginate_path: /posts/page/:num/
3+
permalink: /posts/:categories/:year/:month/:day/:title/index:output_ext
14
defaults:
25
- values:
3-
layout: bootstrap_5.2.3
6+
layout: bootstrap_5.2.3
7+
- scope:
8+
type: posts
9+
values:
10+
layout: post

CodeMap.Documentation/GitHub Pages/_layouts/bootstrap_5.2.3.html

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@
2121

2222
<div class="collapse navbar-collapse" id="navbarSupportedContent">
2323
<ul class="navbar-nav ms-auto">
24+
{% if site.posts.size > 0 %}
25+
<li class="nav-item">
26+
{% assign is_post_page = false %}
27+
{% if page.path == 'posts/index.html' %}
28+
{% assign is_post_page = true %}
29+
{% else %}
30+
{% for post in site.posts %}
31+
{% if post == page %}
32+
{% assign is_post_page = true %}
33+
{% break %}
34+
{% endif %}
35+
{% endfor %}
36+
{% endif %}
37+
<a class="nav-link{% if is_post_page %} active{% endif %}" href="{{ 'posts' | relative_url }}">Posts</a>
38+
</li>
39+
{% endif %}
2440
<li class="nav-item dropdown">
2541
<a class="nav-link dropdown-toggle{% if page.version %} active{% endif %}" role="button" data-bs-toggle="dropdown" aria-expanded="false">
2642
Documentation
@@ -58,17 +74,19 @@
5874
</div>
5975
</nav>
6076

61-
<div class="mt-2 mx-3 flex-fill">
77+
<div class="mt-2 mx-3 d-flex flex-column flex-fill">
6278
{{ content }}
6379
</div>
6480

6581
<footer class="mt-2 px-3 py-2 border-top text-center">
66-
{% if site.data.tags contains page.version %}
67-
<a href="{{site.github.repository_url}}/releases/tag/{{ page.version }}">{{ site.github.repository_name }} {{ page.version }}</a>
68-
{% else %}
69-
<a href="{{site.github.repository_url}}/tree/{{ page.version }}">{{ site.github.repository_name }}@{{ page.version }}</a>
70-
{% endif %}
82+
{% if page.version %}
83+
{% if site.data.tags contains page.version %}
84+
<a href="{{site.github.repository_url}}/releases/tag/{{ page.version }}">{{ site.github.repository_name }} {{ page.version }}</a>
85+
{% else %}
86+
<a href="{{site.github.repository_url}}/tree/{{ page.version }}">{{ site.github.repository_name }}@{{ page.version }}</a>
87+
{% endif %}
7188
-
89+
{% endif %}
7290
<a href="{{site.github.repository_url}}">View on GitHub</a>
7391
-
7492
{% if site.data.tags contains page.version %}
@@ -80,4 +98,4 @@
8098

8199
<script src="{{ 'assets/bootstrap/5.2.3/bootstrap.bundle.min.js' | relative_url }}"></script>
82100
</body>
83-
</html>
101+
</html>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
layout: bootstrap_5.2.3
3+
---
4+
{% assign post_index = 0 %}
5+
{% for post in site.posts %}
6+
{% if post == page %}
7+
{% assign post_index = forloop.index0 %}
8+
{% break %}
9+
{% endif %}
10+
{% endfor %}
11+
{% assign post_page_number = post_index | divided_by: site.paginate | plus: 1 %}
12+
13+
<h1 class="mb-0">{{ page.title }} | <small><a href="{% if post_page_number == 1 %}{{ '/posts' | relative_url }}{% else %}{{ '/posts/page/' | append: post_page_number | relative_url }}{% endif %}">back</a></small></h1>
14+
<p class="{% if page.tags.size > 0 %}mb-0 {% endif %}fst-italic fw-light"><small>Posted on {{ page.date | date: '%A, %-d %B %Y' }}</small></p>
15+
{% if page.tags.size > 0 %}
16+
<p>
17+
<small>
18+
{% for tag in page.tags %}
19+
<span class="badge text-bg-primary">{{ tag }}</span>
20+
{% endfor %}
21+
</small>
22+
</p>
23+
{% endif %}
24+
25+
{{ content }}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: CodeMap - Posts
3+
---
4+
<h1 class="mb-4">CodeMap Posts</h1>
5+
6+
<div class="flex-fill">
7+
{% for post in paginator.posts %}
8+
{% unless forloop.first %}<hr>{% endunless %}
9+
{% assign post_url_index_length = '/index.html' | size %}
10+
{% assign post_url_length = post.url | size | minus: post_url_index_length %}
11+
{% assign post_url = post.url | slice: 0, post_url_length %}
12+
<h3 class="mb-0"><a href="{{ post_url | relative_url }}">{{ post.title }}</a></h3>
13+
<p class="{% if post.tags.size > 0 %}mb-0 {% endif %}fst-italic fw-light"><small>Posted on {{ post.date | date: '%A, %-d %B %Y' }}</small></p>
14+
{% if post.tags.size > 0 %}
15+
<p>
16+
<small>
17+
{% for tag in post.tags %}
18+
<span class="badge text-bg-primary">{{ tag }}</span>
19+
{% endfor %}
20+
</small>
21+
</p>
22+
{% endif %}
23+
{{ post.excerpt }}
24+
{% endfor %}
25+
</div>
26+
27+
<nav>
28+
<ul class="mt-3 pagination pagination-sm justify-content-center">
29+
{% assign page_offset_range = (0..4) %}
30+
{% assign page_offset_previous = page_offset_range | size | divided_by: 2 %}
31+
32+
{% if paginator.page == 1 %}
33+
<li class="page-item disabled">
34+
<span class="page-link">First</span>
35+
</li>
36+
{% else %}
37+
<li class="page-item">
38+
<a class="page-link" href="{{ '/posts' | relative_url }}">First</a>
39+
</li>
40+
{% endif %}
41+
42+
{% for page_offset in page_offset_range %}
43+
{% assign page = paginator.page | plus: page_offset | minus: page_offset_previous %}
44+
45+
{% if forloop.first and page > 1 %}
46+
<li class="page-item disabled">
47+
<span class="page-link">...</span>
48+
</li>
49+
{% endif %}
50+
51+
{% if 1 <= page and page <= paginator.total_pages %}
52+
{% if page == paginator.page %}
53+
<li class="page-item active">
54+
<span class="page-link">{{ page }}</span>
55+
</li>
56+
{% else %}
57+
<li class="page-item">
58+
<a class="page-link" href="{% if page == 1 %}{{ '/posts' | relative_url }}{% else %}{{ '/posts/page/' | append: page | relative_url }}{% endif %}">{{ page }}</a>
59+
</li>
60+
{% endif %}
61+
{% endif %}
62+
63+
{% if forloop.last and page < paginator.total_pages %}
64+
<li class="page-item disabled">
65+
<span class="page-link">...</span>
66+
</li>
67+
{% endif %}
68+
{% endfor %}
69+
70+
{% if paginator.page == paginator.total_pages %}
71+
<li class="page-item disabled">
72+
<span class="page-link">Last</span>
73+
</li>
74+
{% else %}
75+
<li class="page-item">
76+
<a class="page-link" href="{% if paginator.total_pages == 1 %}{{ '/posts' | relative_url }}{% else %}{{ '/posts/page/' | append: paginator.total_pages | relative_url }}{% endif %}">Last</a>
77+
</li>
78+
{% endif %}
79+
</ul>
80+
</nav>

0 commit comments

Comments
 (0)