Skip to content

Commit

Permalink
adding _includes and _layout folders
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorciney committed Nov 21, 2023
1 parent 0b2a25d commit 790b856
Show file tree
Hide file tree
Showing 32 changed files with 1,569 additions and 3 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ description: >- # used by seo meta and the atom feed
# Fill in the protocol & hostname for your site.
# e.g. 'https://username.github.io', note that it does not end with a '/'.
url: "https://jorciney.github.io"
url: "https://jorciney.dev"

github:
username: jorciney # change to your github username
Expand Down
5 changes: 5 additions & 0 deletions _includes/comments.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- The comments switcher -->
{% if page.comments and site.comments.active %}
{% capture path %}comments/{{ site.comments.active }}.html{% endcapture %}
{% include {{ path }} %}
{% endif %}
20 changes: 20 additions & 0 deletions _includes/datetime.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
Date format snippet
See: ${JS_ROOT}/utils/locale-dateime.js
-->

{% assign df_strftime = site.data.locales[include.lang].df.post.strftime | default: '%d/%m/%Y' %}
{% assign df_dayjs = site.data.locales[include.lang].df.post.dayjs | default: 'DD/MM/YYYY' %}

<time
{% if include.class %}
class="{{ include.class }}"
{% endif %}
data-ts="{{ include.date | date: '%s' }}"
data-df="{{ df_dayjs }}"
{% if include.tooltip %}
data-bs-toggle="tooltip" data-bs-placement="bottom"
{% endif %}
>
{{ include.date | date: df_strftime }}
</time>
17 changes: 17 additions & 0 deletions _includes/favicons.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!--
The Favicons for Web, Android, Microsoft, and iOS (iPhone and iPad) Apps
Generated by: https://realfavicongenerator.net/
-->

{% capture favicon_path %}{{ '/assets/img/favicons' | relative_url }}{% endcapture %}

<link rel="apple-touch-icon" sizes="180x180" href="{{ favicon_path }}/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="{{ favicon_path }}/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="{{ favicon_path }}/favicon-16x16.png">
<link rel="manifest" href="{{ favicon_path }}/site.webmanifest">
<link rel="shortcut icon" href="{{ favicon_path }}/favicon.ico">
<meta name="apple-mobile-web-app-title" content="{{ site.title }}">
<meta name="application-name" content="{{ site.title }}">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="{{ favicon_path }}/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
36 changes: 36 additions & 0 deletions _includes/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!-- The Footer -->

<footer
aria-label="Site Info"
class="
d-flex flex-column justify-content-center text-muted
flex-lg-row justify-content-lg-between align-items-lg-center pb-lg-3
"
>
<p>
{{ '©' }}
<time>{{ 'now' | date: '%Y' }}</time>
<a href="{{ site.social.links[0] }}">{{ site.social.name }}</a>.
{% if site.data.locales[include.lang].copyright.brief %}
<span
data-bs-toggle="tooltip"
data-bs-placement="top"
title="{{ site.data.locales[include.lang].copyright.verbose }}"
>
{{- site.data.locales[include.lang].copyright.brief -}}
</span>
{% endif %}
</p>

<p>
{%- capture _platform -%}
<a href="https://jekyllrb.com" target="_blank" rel="noopener">Jekyll</a>
{%- endcapture -%}

{%- capture _theme -%}
<a href="https://github.com/cotes2020/jekyll-theme-chirpy" target="_blank" rel="noopener">Chirpy</a>
{%- endcapture -%}

{{ site.data.locales[include.lang].meta | replace: ':PLATFORM', _platform | replace: ':THEME', _theme }}
</p>
</footer>
14 changes: 14 additions & 0 deletions _includes/google-analytics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!--
The GA snippet
-->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script defer src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics.id }}"></script>
<script>
document.addEventListener("DOMContentLoaded", function(event) {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}

gtag('js', new Date());
gtag('config', '{{ site.google_analytics.id }}');
});
</script>
99 changes: 99 additions & 0 deletions _includes/head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!-- The Head -->

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#f7f7f7">
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#1b1b1e">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta
name="viewport"
content="width=device-width, user-scalable=no initial-scale=1, shrink-to-fit=no, viewport-fit=cover"
>

{% capture seo_tags %}
{% seo title=false %}
{% endcapture %}

{% if page.image %}
{% assign img = page.image.path | default: page.image %}

{% unless img contains '://' %}
{% assign img_path = page.img_path | append: '/' | append: img | replace: '//', '/' %}
{% capture target %}"{{ img | absolute_url }}"{% endcapture %}

{% if site.img_cdn contains '//' %}
<!-- it's a cross-origin URL -->
{% capture replacement %}"{{ site.img_cdn }}{{ img_path }}"{% endcapture %}
{% else %}
<!-- it's a local file path -->
{%- capture replacement -%}
"{{ site.img_cdn | append: '/' | append: img_path | replace: '//', '/' | absolute_url }}"
{%- endcapture -%}
{% endif %}

{% assign seo_tags = seo_tags | replace: target, replacement %}
{% endunless %}
{% endif %}

{{ seo_tags }}

<title>
{%- unless page.layout == 'home' -%}
{{ page.title | append: ' | ' }}
{%- endunless -%}
{{ site.title }}
</title>

{% include_cached favicons.html %}

{% if site.resources.ignore_env != jekyll.environment and site.resources.self_hosted %}
<link href="{{ site.data.origin[type].webfonts | relative_url }}" rel="stylesheet">

{% else %}
{% for cdn in site.data.origin[type].cdns %}
<link rel="preconnect" href="{{ cdn.url }}" {{ cdn.args }}>
<link rel="dns-prefetch" href="{{ cdn.url }}" {{ cdn.args }}>
{% endfor %}

<link rel="stylesheet" href="{{ site.data.origin[type].webfonts | relative_url }}">
{% endif %}

<!-- GA -->
{% if jekyll.environment == 'production' and site.google_analytics.id != empty and site.google_analytics.id %}
<link rel="preconnect" href="https://www.google-analytics.com" crossorigin="use-credentials">
<link rel="dns-prefetch" href="https://www.google-analytics.com">

<link rel="preconnect" href="https://www.googletagmanager.com" crossorigin="anonymous">
<link rel="dns-prefetch" href="https://www.googletagmanager.com">
{% endif %}

<!-- Bootstrap -->
<link rel="stylesheet" href="{{ site.data.origin[type].bootstrap.css | relative_url}}">

<!-- Font Awesome -->
<link rel="stylesheet" href="{{ site.data.origin[type].fontawesome.css | relative_url }}">

<link rel="stylesheet" href="{{ '/assets/css/:THEME.css' | replace: ':THEME', site.theme | relative_url }}">

{% if site.toc and page.toc %}
<link rel="stylesheet" href="{{ site.data.origin[type].toc.css | relative_url }}">
{% endif %}

{% if page.layout == 'post' or page.layout == 'page' or page.layout == 'home' %}
<link rel="stylesheet" href="{{ site.data.origin[type]['lazy-polyfill'].css | relative_url }}">
{% endif %}

{% if page.layout == 'page' or page.layout == 'post' %}
<!-- Manific Popup -->
<link rel="stylesheet" href="{{ site.data.origin[type].magnific-popup.css | relative_url }}">
{% endif %}

<!-- JavaScript -->

{% unless site.theme_mode %}
{% include mode-toggle.html %}
{% endunless %}

{% include metadata-hook.html %}
</head>
106 changes: 106 additions & 0 deletions _includes/js-selector.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<!-- JS selector for site. -->

<!-- commons -->

{% assign urls = site.data.origin[type].jquery.js
| append: ','
| append: site.data.origin[type].bootstrap.js
| append: ','
| append: site.data.origin[type].search.js
%}

<!-- layout specified -->

{% if page.layout == 'post' or page.layout == 'page' or page.layout == 'home' %}
{% assign urls = urls | append: ',' | append: site.data.origin[type]['lazy-polyfill'].js %}

{% unless page.layout == 'home' %}
<!-- image lazy-loading & popup & clipboard -->
{% assign urls = urls
| append: ','
| append: site.data.origin[type]['magnific-popup'].js
| append: ','
| append: site.data.origin[type].clipboard.js
%}
{% endunless %}
{% endif %}

{% if page.layout == 'home'
or page.layout == 'post'
or page.layout == 'archives'
or page.layout == 'category'
or page.layout == 'tag'
%}
{% assign locale = site.lang | split: '-' | first %}

{% assign urls = urls
| append: ','
| append: site.data.origin[type].dayjs.js.common
| append: ','
| append: site.data.origin[type].dayjs.js.locale
| replace: ':LOCALE', locale
| append: ','
| append: site.data.origin[type].dayjs.js.relativeTime
| append: ','
| append: site.data.origin[type].dayjs.js.localizedFormat
%}
{% endif %}

{% if page.content contains '<h2' or page.content contains '<h3' and site.toc and page.toc %}
{% assign urls = urls | append: ',' | append: site.data.origin[type].toc.js %}
{% endif %}

{% if page.mermaid %}
{% assign urls = urls | append: ',' | append: site.data.origin[type].mermaid.js %}
{% endif %}

{% include jsdelivr-combine.html urls=urls %}

{% case page.layout %}
{% when 'home', 'categories', 'post', 'page' %}
{% assign js = page.layout %}
{% when 'archives', 'category', 'tag' %}
{% assign js = 'misc' %}
{% else %}
{% assign js = 'commons' %}
{% endcase %}

{% capture script %}/assets/js/dist/{{ js }}.min.js{% endcapture %}
<script defer src="{{ script | relative_url }}"></script>

{% if page.math %}
<!-- MathJax -->
<script>
/* see: <https://docs.mathjax.org/en/latest/options/input/tex.html#tex-options> */
MathJax = {
tex: {
/* start/end delimiter pairs for in-line math */
inlineMath: [
['$', '$'],
['\\(', '\\)']
],
/* start/end delimiter pairs for display math */
displayMath: [
['$$', '$$'],
['\\[', '\\]']
]
}
};
</script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="{{ site.data.origin[type].mathjax.js | relative_url }}"></script>
{% endif %}

{% if jekyll.environment == 'production' %}
<!-- PWA -->
{% if site.pwa.enabled %}
<script defer src="{{ '/app.js' | relative_url }}"></script>
{% else %}
<script defer src="{{ '/unregister.js' | relative_url }}"></script>
{% endif %}

<!-- GA -->
{% if site.google_analytics.id != empty and site.google_analytics.id %}
{% include google-analytics.html %}
{% endif %}
{% endif %}
26 changes: 26 additions & 0 deletions _includes/jsdelivr-combine.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% assign urls = include.urls | split: ',' %}

{% assign combined_urls = nil %}

{% assign domain = 'https://cdn.jsdelivr.net/' %}

{% for url in urls %}
{% if url contains domain %}
{% assign url_snippet = url | slice: domain.size, url.size %}

{% if combined_urls %}
{% assign combined_urls = combined_urls | append: ',' | append: url_snippet %}
{% else %}
{% assign combined_urls = domain | append: 'combine/' | append: url_snippet %}
{% endif %}

{% elsif url contains '//' %}
<script src="{{ url }}"></script>
{% else %}
<script src="{{ url | relative_url }}"></script>
{% endif %}
{% endfor %}

{% if combined_urls %}
<script src="{{ combined_urls }}"></script>
{% endif %}
8 changes: 8 additions & 0 deletions _includes/lang.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% comment %}
Detect appearance language and return it through variable "lang"
{% endcomment %}
{% if site.data.locales[site.lang] %}
{% assign lang = site.lang %}
{% else %}
{% assign lang = 'en' %}
{% endif %}
Loading

0 comments on commit 790b856

Please sign in to comment.