First I'd like to thank Brad West who provided the base, thank you.
Attention: Tested only on standard github pages dependency, not tested
on v2, not tested outside of github pages dependency.
The code below is working perfectly on gitgub pages (Jekyll v3.9.2), so far I have not found bugs.
I could have spent more time and improved the code, but it's already working as it should, so I'm not going to waste any more time on it.
Result: before and after.

_config.yml
paginate: 10
paginate_path: /page/:num/
.pagination {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 3rem;
}
.pagination a,
.pagination span {
display: flex;
justify-content: center;
align-items: center;
width: 40px;
height: 40px;
border: 1px solid #efefef;
border-left: 0;
}
.pagination .active {
background: #f3f3f3;
pointer-events: none;
}
.pagination .active svg {
opacity: .3;
}
.pagination a:hover {
background: #f3f3f3;
cursor: pointer;
}
.pagination a:first-child,
.pagination span:first-child {
border-left: 1px solid #efefef;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
}
.pagination a:last-child,
.pagination span:last-child {
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
}
{% if paginator.total_pages > 1 %}
<div class="pagination">
{% if paginator.previous_page %}
<a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">
<svg width="8" height="16" viewBox="0 0 8 13">
<g fill="none" stroke="none" stroke-width="1" fill-rule="evenodd">
<g transform="translate(1.000000, 1.000000)" stroke="currentColor" stroke-width="2">
<polyline transform="translate(3.500000, 5.507797) rotate(90.000000) translate(-3.500000, -5.507797)" points="-1.5 3 3.5155939 8.0155939 8.5 3.0311879"></polyline>
</g>
</g>
</svg>
</a>
{% else %}
<span class="active">
<svg width="8" height="16" viewBox="0 0 8 13">
<g fill="none" stroke="none" stroke-width="1" fill-rule="evenodd">
<g transform="translate(1.000000, 1.000000)" stroke="currentColor" stroke-width="2">
<polyline transform="translate(3.500000, 5.507797) rotate(90.000000) translate(-3.500000, -5.507797)" points="-1.5 3 3.5155939 8.0155939 8.5 3.0311879"></polyline>
</g>
</g>
</svg>
</span>
{% endif %}
{% for page in (1..paginator.total_pages) %}
{% assign last_five = forloop.length | minus: 4 %}
{% assign last_page = forloop.length %}
{% if forloop.length > 5 %}
{% if paginator.page <= 5 %}
{% if forloop.index <= 5 %}
{% if forloop.first and page == paginator.page %}
<span class="active">{{ page }}</span>
{% elsif forloop.first %}
<a href="/">1</a>
{% elsif page == paginator.page %}
<span class="active">{{ page }}</span>
{% else %}
<a href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', page }}">{{ page }}</a>
{% endif %}
{% else %}
{% if paginator.page == 5 %}
<a href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}">{{ page }}</a>
{% endif %}
<span>...</span>
<a href="/page/{{ last_page }}/">{{ last_page }}</a>
{% break %}
{% endif %}
{% elsif paginator.page >= last_five %}
{% if forloop.index >= last_five %}
{% if forloop.index == last_five %}
<a href="/">1</a>
<span>...</span>
{% if page == last_five %}
<a href="/page/{{ page | minus: 1 }}/">{{ page | minus: 1 }}</a>
{% endif %}
{% if page == paginator.page %}
<span class="active">{{ page }}</span>
{% else %}
<a href="/page/{{ page }}/">{{ page }}</a>
{% endif %}
{% elsif forloop.last and page == paginator.page %}
<span class="active">{{ page }}</span>
{% elsif page == paginator.page %}
<span class="active">{{ page }}</span>
{% else %}
<a href="/page/{{ page }}/">{{ page }}</a>
{% endif %}
{% endif %}
{% else %}
{% if forloop.first %}
<a href="/">1</a>
{% endif %}
{% if forloop.index == paginator.page | minus: 2 %}
<span>...</span>
<a href="/page/{{ page | minus: 2 }}/">{{ page | minus: 2 }}</a>
{% endif %}
{% if forloop.index == paginator.page | minus: 1 %}
<a href="/page/{{ page | minus: 1 }}/">{{ page | minus: 1 }}</a>
{% endif %}
{% if page == paginator.page %}
<span class="active">{{ page }}</span>
{% endif %}
{% if forloop.index == paginator.page | plus: 1 %}
<a href="/page/{{ page | plus: 1 }}/">{{ page | plus: 1 }}</a>
{% endif %}
{% if forloop.index == paginator.page | plus: 2 %}
<a href="/page/{{ page | plus: 2 }}/">{{ page | plus: 2 }}</a>
<span>...</span>
{% endif %}
{% if forloop.last %}
<a href="/page/{{ forloop.index }}/">{{ forloop.index }}</a>
{% endif %}
{% endif %}
{% else %}
{% if page == paginator.page %}
<span class="active">{{ page }}</span>
{% elsif page == 1 %}
<a href="/">{{ page }}</a>
{% else %}
<a href="/page/{{ page }}/">{{ page }}</a>
{% endif %}
{% endif %}
{% endfor %}
{% if paginator.next_page %}
<a href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}">
<svg width="8" height="16" viewBox="0 0 8 13">
<g fill="none" stroke="none" stroke-width="1" fill-rule="evenodd">
<g transform="translate(-2.000000, 4.000000)" stroke="currentColor" stroke-width="2">
<polyline transform="translate(5.500000, 2.500000) rotate(90.000000) translate(-5.500000, -2.500000)" points="10.5 5 5.5 6.66133815e-16 0.5 5"></polyline>
</g>
</g>
</svg>
</a>
{% else %}
<span class="active">
<svg width="8" height="16" viewBox="0 0 8 13">
<g fill="none" stroke="none" stroke-width="1" fill-rule="evenodd">
<g transform="translate(-2.000000, 4.000000)" stroke="currentColor" stroke-width="2">
<polyline transform="translate(5.500000, 2.500000) rotate(90.000000) translate(-5.500000, -2.500000)" points="10.5 5 5.5 6.66133815e-16 0.5 5"></polyline>
</g>
</g>
</svg>
</span>
{% endif %}
</div>
{% endif %}