Skip to content

Commit

Permalink
Added Posts (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei15193 authored Jul 3, 2023
1 parent f06c053 commit f332d04
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 18 deletions.
28 changes: 18 additions & 10 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,29 +198,37 @@ jobs:
return $versionParts
}
[string] $documentationDirectoryPath = if ('${{ github.event_name }}' -ieq 'release' -or '${{ github.ref_name }}' -ieq 'dev') { '${{ github.ref_name }}' } else { 'dev/${{ github.ref_name }}' }
dotnet run `
--project CodeMap.Documentation `
--configuration Release `
--no-build `
-- `
-OutputFilePath "./docs/$documentationDirectoryPath/index.html"
New-Item `
-Type Directory `
-Name docs `
-ErrorAction SilentlyContinue
-ErrorAction SilentlyContinue `
| Out-Null
New-Item `
-Type Directory `
-Name _data `
-Path docs `
-ErrorAction SilentlyContinue
-ErrorAction SilentlyContinue `
| Out-Null
[string] $documentationDirectoryPath = if ('${{ github.event_name }}' -ieq 'release' -or '${{ github.ref_name }}' -ieq 'dev') { '${{ github.ref_name }}' } else { 'dev/${{ github.ref_name }}' }
dotnet run `
--project CodeMap.Documentation `
--configuration Release `
--no-build `
-- `
-OutputFilePath "./docs/$documentationDirectoryPath/index.html"
if (Test-Path 'CodeMap.Documentation/GitHub Pages') {
Copy-Item `
-Path 'CodeMap.Documentation/GitHub Pages/*' `
-Destination './docs' `
-Recurse
if (('${{ github.ref_name }}' -ine 'dev') -and (Test-Path './docs/_posts')) {
Remove-Item `
-Path './docs/_posts' `
-Recurse
}
}
Sort-SemVerDescending (
Expand Down
9 changes: 8 additions & 1 deletion CodeMap.Documentation/GitHub Pages/_config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
paginate: 10
paginate_path: /posts/page/:num/
permalink: /posts/:categories/:year/:month/:day/:title/index:output_ext
defaults:
- values:
layout: bootstrap_5.2.3
layout: bootstrap_5.2.3
- scope:
type: posts
values:
layout: post
32 changes: 25 additions & 7 deletions CodeMap.Documentation/GitHub Pages/_layouts/bootstrap_5.2.3.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto">
{% if site.posts.size > 0 %}
<li class="nav-item">
{% assign is_post_page = false %}
{% if page.path == 'posts/index.html' %}
{% assign is_post_page = true %}
{% else %}
{% for post in site.posts %}
{% if post == page %}
{% assign is_post_page = true %}
{% break %}
{% endif %}
{% endfor %}
{% endif %}
<a class="nav-link{% if is_post_page %} active{% endif %}" href="{{ 'posts' | relative_url }}">Posts</a>
</li>
{% endif %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle{% if page.version %} active{% endif %}" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Documentation
Expand Down Expand Up @@ -58,17 +74,19 @@
</div>
</nav>

<div class="mt-2 mx-3 flex-fill">
<div class="mt-2 mx-3 d-flex flex-column flex-fill">
{{ content }}
</div>

<footer class="mt-2 px-3 py-2 border-top text-center">
{% if site.data.tags contains page.version %}
<a href="{{site.github.repository_url}}/releases/tag/{{ page.version }}">{{ site.github.repository_name }} {{ page.version }}</a>
{% else %}
<a href="{{site.github.repository_url}}/tree/{{ page.version }}">{{ site.github.repository_name }}@{{ page.version }}</a>
{% endif %}
{% if page.version %}
{% if site.data.tags contains page.version %}
<a href="{{site.github.repository_url}}/releases/tag/{{ page.version }}">{{ site.github.repository_name }} {{ page.version }}</a>
{% else %}
<a href="{{site.github.repository_url}}/tree/{{ page.version }}">{{ site.github.repository_name }}@{{ page.version }}</a>
{% endif %}
-
{% endif %}
<a href="{{site.github.repository_url}}">View on GitHub</a>
-
{% if site.data.tags contains page.version %}
Expand All @@ -80,4 +98,4 @@

<script src="{{ 'assets/bootstrap/5.2.3/bootstrap.bundle.min.js' | relative_url }}"></script>
</body>
</html>
</html>
25 changes: 25 additions & 0 deletions CodeMap.Documentation/GitHub Pages/_layouts/post.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
layout: bootstrap_5.2.3
---
{% assign post_index = 0 %}
{% for post in site.posts %}
{% if post == page %}
{% assign post_index = forloop.index0 %}
{% break %}
{% endif %}
{% endfor %}
{% assign post_page_number = post_index | divided_by: site.paginate | plus: 1 %}

<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>
<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>
{% if page.tags.size > 0 %}
<p>
<small>
{% for tag in page.tags %}
<span class="badge text-bg-primary">{{ tag }}</span>
{% endfor %}
</small>
</p>
{% endif %}

{{ content }}
80 changes: 80 additions & 0 deletions CodeMap.Documentation/GitHub Pages/posts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
title: CodeMap - Posts
---
<h1 class="mb-4">CodeMap Posts</h1>

<div class="flex-fill">
{% for post in paginator.posts %}
{% unless forloop.first %}<hr>{% endunless %}
{% assign post_url_index_length = '/index.html' | size %}
{% assign post_url_length = post.url | size | minus: post_url_index_length %}
{% assign post_url = post.url | slice: 0, post_url_length %}
<h3 class="mb-0"><a href="{{ post_url | relative_url }}">{{ post.title }}</a></h3>
<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>
{% if post.tags.size > 0 %}
<p>
<small>
{% for tag in post.tags %}
<span class="badge text-bg-primary">{{ tag }}</span>
{% endfor %}
</small>
</p>
{% endif %}
{{ post.excerpt }}
{% endfor %}
</div>

<nav>
<ul class="mt-3 pagination pagination-sm justify-content-center">
{% assign page_offset_range = (0..4) %}
{% assign page_offset_previous = page_offset_range | size | divided_by: 2 %}

{% if paginator.page == 1 %}
<li class="page-item disabled">
<span class="page-link">First</span>
</li>
{% else %}
<li class="page-item">
<a class="page-link" href="{{ '/posts' | relative_url }}">First</a>
</li>
{% endif %}

{% for page_offset in page_offset_range %}
{% assign page = paginator.page | plus: page_offset | minus: page_offset_previous %}

{% if forloop.first and page > 1 %}
<li class="page-item disabled">
<span class="page-link">...</span>
</li>
{% endif %}

{% if 1 <= page and page <= paginator.total_pages %}
{% if page == paginator.page %}
<li class="page-item active">
<span class="page-link">{{ page }}</span>
</li>
{% else %}
<li class="page-item">
<a class="page-link" href="{% if page == 1 %}{{ '/posts' | relative_url }}{% else %}{{ '/posts/page/' | append: page | relative_url }}{% endif %}">{{ page }}</a>
</li>
{% endif %}
{% endif %}

{% if forloop.last and page < paginator.total_pages %}
<li class="page-item disabled">
<span class="page-link">...</span>
</li>
{% endif %}
{% endfor %}

{% if paginator.page == paginator.total_pages %}
<li class="page-item disabled">
<span class="page-link">Last</span>
</li>
{% else %}
<li class="page-item">
<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>
</li>
{% endif %}
</ul>
</nav>

0 comments on commit f332d04

Please sign in to comment.