diff --git a/_includes/comments.html b/_includes/comments.html new file mode 100644 index 0000000..39e521f --- /dev/null +++ b/_includes/comments.html @@ -0,0 +1,5 @@ + +{% if page.comments and site.comments.active %} + {% capture path %}comments/{{ site.comments.active }}.html{% endcapture %} + {% include {{ path }} %} +{% endif %} diff --git a/_includes/comments/disqus.html b/_includes/comments/disqus.html new file mode 100644 index 0000000..d2f59df --- /dev/null +++ b/_includes/comments/disqus.html @@ -0,0 +1,49 @@ + +
' %}
+ {% assign content = content | replace: '', '' %}
+{% endif %}
diff --git a/_includes/origin-type.html b/_includes/origin-type.html
new file mode 100644
index 0000000..7f72012
--- /dev/null
+++ b/_includes/origin-type.html
@@ -0,0 +1,13 @@
+{% comment %} Site static assets origin type {% endcomment %}
+
+{% assign type = 'cors' %}
+
+{% if site.assets.self_host.enabled %}
+ {% if site.assets.self_host.env %}
+ {% if site.assets.self_host.env == jekyll.environment %}
+ {% assign type = 'basic' %}
+ {% endif %}
+ {% else %}
+ {% assign type = 'basic' %}
+ {% endif %}
+{% endif %}
diff --git a/_includes/post-nav.html b/_includes/post-nav.html
new file mode 100644
index 0000000..76bcd59
--- /dev/null
+++ b/_includes/post-nav.html
@@ -0,0 +1,37 @@
+
+
+
diff --git a/_includes/post-paginator.html b/_includes/post-paginator.html
new file mode 100644
index 0000000..c432d1b
--- /dev/null
+++ b/_includes/post-paginator.html
@@ -0,0 +1,89 @@
+
+
+
+
+ {% if paginator.previous_page %}
+ {% assign prev_url = paginator.previous_page_path | relative_url %}
+ {% else %}
+ {% assign prev_url = '#' %}
+ {% endif %}
+
+ -
+
+
+
+
+
+
+ {% assign left_ellipsis = false %}
+ {% assign right_ellipsis = false %}
+
+ {% for i in (1..paginator.total_pages) %}
+ {% assign pre = paginator.page | minus: 1 %}
+ {% assign next = paginator.page | plus: 1 %}
+ {% assign pre_less = pre | minus: 1 %}
+ {% assign next_more = next | plus: 1 %}
+ {% assign show = false %}
+
+ {% if paginator.page == 1 %}
+ {% if i <= 3 or i == paginator.total_pages %}
+ {% assign show = true %}
+ {% endif %}
+ {% elsif paginator.page == paginator.total_pages %}
+ {% if i == 1 or i >= pre_less %}
+ {% assign show = true %}
+ {% endif %}
+ {% else %}
+ {% if i == 1 or i == paginator.total_pages %}
+ {% assign show = true %}
+ {% elsif i >= pre and i <= next %}
+ {% assign show = true %}
+ {% endif %}
+ {% endif %}
+
+ {% if show %}
+
+ -
+
+ {{- i -}}
+
+
+ {% else %}
+
+ {% if i < pre and left_ellipsis == false %}
+ -
+ ...
+
+ {% assign left_ellipsis = true %}
+ {% elsif i > next and right_ellipsis == false %}
+ -
+ ...
+
+ {% assign right_ellipsis = true %}
+ {% endif %}
+ {% endif %}
+ {% endfor %}
+
+
+ -
+ {{ paginator.page }}
+ / {{ paginator.total_pages }}
+
+
+
+ {% if paginator.next_page_path %}
+ {% assign next_url = paginator.next_page_path | relative_url %}
+ {% else %}
+ {% assign next_url = '#' %}
+ {% endif %}
+
+ -
+
+
+
+
+
+
diff --git a/_includes/post-sharing.html b/_includes/post-sharing.html
new file mode 100644
index 0000000..f607ba2
--- /dev/null
+++ b/_includes/post-sharing.html
@@ -0,0 +1,35 @@
+
+
+
diff --git a/_includes/read-time.html b/_includes/read-time.html
new file mode 100644
index 0000000..9952410
--- /dev/null
+++ b/_includes/read-time.html
@@ -0,0 +1,37 @@
+
+
+{% assign words = include.content | strip_html | number_of_words: 'auto' %}
+
+
+
+{% assign wpm = 180 %}
+{% assign min_time = 1 %}
+
+{% assign read_time = words | divided_by: wpm %}
+
+{% unless read_time > 0 %}
+ {% assign read_time = min_time %}
+{% endunless %}
+
+{% capture read_prompt %}
+ {{- site.data.locales[include.lang].post.read_time.prompt -}}
+{% endcapture %}
+
+
+
+
+ {{- read_time -}}
+ {{ ' ' }}
+ {{- site.data.locales[include.lang].post.read_time.unit -}}
+
+ {%- if include.prompt -%}
+ {%- assign _prompt_words = read_prompt | number_of_words: 'auto' -%}
+ {%- unless _prompt_words > 1 -%}{{ ' ' }}{%- endunless -%}
+ {{ read_prompt }}
+ {%- endif -%}
+
diff --git a/_includes/refactor-content.html b/_includes/refactor-content.html
new file mode 100644
index 0000000..655ecd6
--- /dev/null
+++ b/_includes/refactor-content.html
@@ -0,0 +1,286 @@
+
+
+{% assign _content = include.content %}
+
+
+
+{% if _content contains '', '
'
+ | replace: '', ''
+ | replace: '
', ''
+ %}
+{% endif %}
+
+
+
+{% if _content contains '' %}
+ {% assign _content = _content
+ | replace: '
', ''
+ %}
+{% endif %}
+
+
+{% if _content contains '',
+ ''
+ | replace:
+ '',
+ ''
+ %}
+{% endif %}
+
+
+{% assign IMG_TAG = '
+ {% if site.img_cdn %}
+ {% if site.img_cdn contains '//' %}
+ {% assign _path_prefix = site.img_cdn %}
+ {% else %}
+ {% assign _path_prefix = site.img_cdn | relative_url %}
+ {% endif %}
+ {% else %}
+ {% assign _path_prefix = site.baseurl %}
+ {% endif %}
+
+
+ {% if page.img_path %}
+ {% assign _path = page.img_path | append: '/' | replace: '//', '/' %}
+ {% assign _path_prefix = _path_prefix | append: _path %}
+ {% endif %}
+
+ {% for _img_snippet in _img_snippets %}
+ {% if forloop.first %}
+ {% assign _img_content = _img_snippet %}
+ {% continue %}
+ {% endif %}
+
+ {% assign _left = _img_snippet | split: '>' | first %}
+ {% assign _right = _img_snippet | remove: _left %}
+
+ {% unless _left contains 'src=' %}
+ {% continue %}
+ {% endunless %}
+
+ {% assign _left = _left | remove: ' /' | replace: ' w=', ' width=' | replace: ' h=', ' height=' %}
+ {% assign _attrs = _left | split: '" ' %}
+
+ {% assign _width = nil %}
+ {% assign _height = nil %}
+ {% assign _lqip = nil %}
+ {% assign _class = nil %}
+
+ {% for _attr in _attrs %}
+ {% unless _attr contains '=' %}
+ {% continue %}
+ {% endunless %}
+
+ {% assign _pair = _attr | split: '="' %}
+ {% capture _key %}{{ _pair | first }}{% endcapture %}
+ {% capture _value %}{{ _pair | last | remove: '"' }}{% endcapture %}
+
+ {% case _key %}
+ {% when 'width' %}
+ {% assign _width = _value %}
+ {% when 'height' %}
+ {% assign _height = _value %}
+ {% when 'src' %}
+ {% assign _src = _value %}
+ {% when 'lqip' %}
+ {% assign _lqip = _value %}
+ {% when 'class' %}
+ {% assign _class = _value %}
+ {% endcase %}
+ {% endfor %}
+
+
+ {% if _class %}
+ {% capture _old_class %}class="{{ _class }}"{% endcapture %}
+ {% assign _left = _left | remove: _old_class %}
+ {% endif %}
+
+ {% assign _final_src = nil %}
+
+ {% unless _src contains '//' %}
+ {% assign _final_src = _path_prefix | append: _src %}
+ {% capture _src_from %}"{{ _src }}"{% endcapture %}
+ {% capture _src_to %}"{{ _final_src }}"{% endcapture %}
+ {% assign _left = _left | replace: _src_from, _src_to %}
+ {% endunless %}
+
+ {% if _lqip %}
+ {% unless _lqip contains ':' %}
+ {% assign _final_lqip = _path_prefix | append: _lqip %}
+ {% capture _lqip_from %}"{{ _lqip }}"{% endcapture %}
+ {% capture _lqip_to %}"{{ _final_lqip }}"{% endcapture %}
+ {% assign _left = _left | replace: _lqip_from, _lqip_to %}
+ {% endunless %}
+ {% endif %}
+
+
+ {% assign _left = _left | replace: 'src=', 'data-src=' %}
+ {% if _left contains 'class=' %}
+ {% assign _left = _left | replace: 'class="', 'class="lazyload '%}
+ {% else %}
+ {% assign _left = _left | append: ' class="lazyload"' %}
+ {% endif %}
+
+
+ {% if _lqip %}
+ {% assign _left = _left | replace: ' lqip=', ' data-lqip="true" src=' %}
+ {% else %}
+ {% if _width and _height %}
+
+ {%- capture _svg -%}
+ src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 {{ _width }} {{ _height }}'%3E%3C/svg%3E"
+ {%- endcapture -%}
+ {% assign _left = _svg | append: ' ' | append: _left %}
+ {% assign _class = _class | append: ' shimmer' %}
+ {% endif %}
+ {% endif %}
+
+
+ {% assign _left = _left | append: ' data-proofer-ignore' %}
+
+ {% if page.layout == 'home' %}
+
+ {%- capture _wrapper_start -%}
+
+ {%- endcapture -%}
+ {% assign _img_content = _img_content | append: _wrapper_start %}
+ {% assign _right = _right | prepend: '>` is wrapped by `` -->
+ {% assign _parent = _right | slice: 1, 4 %}
+
+ {% if _parent == '' %}
+
+ {% assign _size = _img_content | size | minus: 1 %}
+ {% capture _class %}
+ class="img-link{% unless _lqip %} shimmer{% endunless %}"
+ {% endcapture %}
+ {% assign _img_content = _img_content | slice: 0, _size | append: _class | append: '>' %}
+ {% else %}
+
+ {%- capture _wrapper_start -%}
+
+ {%- endcapture -%}
+ {% assign _img_content = _img_content | append: _wrapper_start %}
+ {% assign _right = _right | prepend: '>
+ {% assign _img_content = _img_content | append: debug | append: IMG_TAG | append: _left | append: _right %}
+
+ {% endfor %}
+
+ {% if _img_content %}
+ {% assign _content = _img_content %}
+ {% endif %}
+
+{% endif %}
+
+
+
+{% if _content contains '' %}
+ {% assign _code_spippets = _content | split: '' %}
+ {% assign _new_content = '' %}
+
+ {% for _snippet in _code_spippets %}
+
+ {% if forloop.last %}
+ {% assign _new_content = _new_content | append: _snippet %}
+
+ {% else %}
+
+ {% assign _left = _snippet | split: '><' | last%}
+
+ {% if _left contains 'file="' %}
+ {% assign _label_text = _left | split: 'file="' | last | split: '"' | first %}
+ {% assign _label_icon = 'far fa-file-code fa-fw' %}
+ {% else %}
+ {% assign _lang = _left | split: 'language-' | last | split: ' ' | first %}
+ {% capture _label_text %}{% include language-alias.html language=_lang %}{% endcapture %}
+ {% assign _label_icon = 'fas fa-code fa-fw small' %}
+ {% endif %}
+
+ {% capture _label %}
+
+ {% endcapture %}
+
+ {% assign _new_content = _new_content | append: _snippet
+ | append: ''
+ | append: _label
+ | append: ''
+ | append: ''
+ %}
+
+ {% endif %}
+
+ {% endfor %}
+
+ {% assign _content = _new_content %}
+
+{% endif %}
+
+
+
+{% assign heading_levels = '2,3,4,5' | split: ',' %}
+{% assign _heading_content = _content %}
+
+{% for level in heading_levels %}
+ {% capture mark_start %}{% endcapture %}
+
+ {% assign left = snippet | split: mark_end | first %}
+ {% assign right = snippet | slice: left.size, snippet.size %}
+ {% assign left = left | replace_first: '">', '">' | append: '' %}
+
+ {% assign _new_content = _new_content | append: mark_start
+ | append: left | append: anchor | append: right
+ %}
+
+ {% endfor %}
+
+ {% assign _heading_content = _new_content %}
+
+ {% endif %}
+{% endfor %}
+
+{% assign _content = _heading_content %}
+
+
+{{ _content }}
diff --git a/_includes/related-posts.html b/_includes/related-posts.html
new file mode 100644
index 0000000..8476a6d
--- /dev/null
+++ b/_includes/related-posts.html
@@ -0,0 +1,104 @@
+
+
+
+{% assign TOTAL_SIZE = 3 %}
+
+
+{% assign TAG_SCORE = 1 %}
+
+
+{% assign CATEGORY_SCORE = 0.5 %}
+
+{% assign SEPARATOR = ':' %}
+
+{% assign score_list = '' | split: '' %}
+{% assign last_index = site.posts.size | minus: 1 %}
+
+{% for i in (0..last_index) %}
+ {% assign post = site.posts[i] %}
+
+ {% if post.url == page.url %}
+ {% continue %}
+ {% endif %}
+
+ {% assign score = 0 %}
+
+ {% for tag in post.tags %}
+ {% if page.tags contains tag %}
+ {% assign score = score | plus: TAG_SCORE %}
+ {% endif %}
+ {% endfor %}
+
+ {% for category in post.categories %}
+ {% if page.categories contains category %}
+ {% assign score = score | plus: CATEGORY_SCORE %}
+ {% endif %}
+ {% endfor %}
+
+ {% if score > 0 %}
+ {% capture score_item %}{{ score }}{{ SEPARATOR }}{{ i }}{% endcapture %}
+ {% assign score_list = score_list | push: score_item %}
+ {% endif %}
+{% endfor %}
+
+{% assign index_list = '' | split: '' %}
+
+{% if score_list.size > 0 %}
+ {% assign score_list = score_list | sort | reverse %}
+ {% for entry in score_list limit: TOTAL_SIZE %}
+ {% assign index = entry | split: SEPARATOR | last %}
+ {% assign index_list = index_list | push: index %}
+ {% endfor %}
+{% endif %}
+
+
+{% assign less = TOTAL_SIZE | minus: index_list.size %}
+
+{% if less > 0 %}
+ {% for i in (0..last_index) %}
+ {% assign post = site.posts[i] %}
+ {% if post.url != page.url %}
+ {% capture cur_index %}{{ i }}{% endcapture %}
+ {% unless index_list contains cur_index %}
+ {% assign index_list = index_list | push: cur_index %}
+ {% assign less = less | minus: 1 %}
+ {% if less <= 0 %}
+ {% break %}
+ {% endif %}
+ {% endunless %}
+ {% endif %}
+ {% endfor %}
+{% endif %}
+
+{% if index_list.size > 0 %}
+
+
+{% endif %}
diff --git a/_includes/search-loader.html b/_includes/search-loader.html
new file mode 100644
index 0000000..634325b
--- /dev/null
+++ b/_includes/search-loader.html
@@ -0,0 +1,45 @@
+
+
+{% capture result_elem %}
+
+ {title}
+
+ {snippet}
+
+{% endcapture %}
+
+{% capture not_found %}{{ site.data.locales[include.lang].search.no_results }}
{% endcapture %}
+
+
diff --git a/_includes/search-results.html b/_includes/search-results.html
new file mode 100644
index 0000000..07981ff
--- /dev/null
+++ b/_includes/search-results.html
@@ -0,0 +1,10 @@
+
+
+
+
+
+ {% include_cached trending-tags.html %}
+
+
+
+
diff --git a/_includes/sidebar.html b/_includes/sidebar.html
new file mode 100644
index 0000000..9fe0208
--- /dev/null
+++ b/_includes/sidebar.html
@@ -0,0 +1,104 @@
+
+
+
+
diff --git a/_includes/toc.html b/_includes/toc.html
new file mode 100644
index 0000000..1eb3dcd
--- /dev/null
+++ b/_includes/toc.html
@@ -0,0 +1,13 @@
+{% assign enable_toc = false %}
+{% if site.toc and page.toc %}
+ {% if page.content contains '
+ {{- site.data.locales[include.lang].panel.toc -}}
+
+
+{% endif %}
diff --git a/_includes/topbar.html b/_includes/topbar.html
new file mode 100644
index 0000000..0092f69
--- /dev/null
+++ b/_includes/topbar.html
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+ {% if page.layout == 'home' %}
+ {{- site.data.locales[include.lang].title | default: site.title -}}
+ {% elsif page.collection == 'tabs' or page.layout == 'page' %}
+ {%- capture tab_key -%}{{ page.url | split: '/' }}{%- endcapture -%}
+ {{- site.data.locales[include.lang].tabs[tab_key] | default: page.title -}}
+ {% else %}
+ {{- site.data.locales[include.lang].layout[page.layout] | default: page.layout | capitalize -}}
+ {% endif %}
+
+
+
+
+
+
+
+ {{ site.data.locales[include.lang].search.cancel }}
+
+
diff --git a/_includes/trending-tags.html b/_includes/trending-tags.html
new file mode 100644
index 0000000..6b1d732
--- /dev/null
+++ b/_includes/trending-tags.html
@@ -0,0 +1,46 @@
+
+
+{% assign MAX = 10 %}
+
+{% assign size_list = '' | split: '' %}
+{% assign tag_list = '' | split: '' %}
+
+{% for tag in site.tags %}
+ {% assign size = tag | last | size %}
+ {% assign size_list = size_list | push: size %}
+
+ {% assign tag_str = tag | first | append: '::' | append: size %}
+ {% assign tag_list = tag_list | push: tag_str %}
+{% endfor %}
+
+{% assign size_list = size_list | sort | reverse %}
+
+{% assign tag_list = tag_list | sort_natural %}
+
+{% assign trending_tags = '' | split: '' %}
+
+{% for size in size_list limit: MAX %}
+ {% for tag_str in tag_list %}
+ {% assign tag = tag_str | split: '::' %}
+ {% assign tag_name = tag | first %}
+ {% assign tag_size = tag | last | plus: 0 %}
+ {% if tag_size == size %}
+ {% unless trending_tags contains tag_name %}
+ {% assign trending_tags = trending_tags | push: tag_name %}
+ {% break %}
+ {% endunless %}
+ {% endif %}
+ {% endfor %}
+{% endfor %}
+
+{% if trending_tags.size > 0 %}
+
+{% endif %}
diff --git a/_includes/update-list.html b/_includes/update-list.html
new file mode 100644
index 0000000..0ab7a45
--- /dev/null
+++ b/_includes/update-list.html
@@ -0,0 +1,39 @@
+
+
+{% assign MAX_SIZE = 5 %}
+
+{% assign all_list = '' | split: '' %}
+
+{% for post in site.posts %}
+ {% if post.last_modified_at and post.last_modified_at != post.date %}
+ {% capture elem %}
+ {{- post.last_modified_at | date: "%Y%m%d%H%M%S" -}}::{{- forloop.index0 -}}
+ {% endcapture %}
+ {% assign all_list = all_list | push: elem %}
+ {% endif %}
+{% endfor %}
+
+{% assign all_list = all_list | sort | reverse %}
+
+{% assign update_list = '' | split: '' %}
+
+{% for entry in all_list limit: MAX_SIZE %}
+ {% assign update_list = update_list | push: entry %}
+{% endfor %}
+
+{% if update_list.size > 0 %}
+
+ {{- site.data.locales[include.lang].panel.lastmod -}}
+
+ {% for item in update_list %}
+ {% assign index = item | split: '::' | last | plus: 0 %}
+ {% assign post = site.posts[index] %}
+ {% assign url = post.url | relative_url %}
+ -
+ {{ post.title }}
+
+ {% endfor %}
+
+
+
+{% endif %}
Comments powered by Disqus.
+