summaryrefslogtreecommitdiff
path: root/_includes/snippets
diff options
context:
space:
mode:
Diffstat (limited to '_includes/snippets')
-rw-r--r--_includes/snippets/assign.html9
-rw-r--r--_includes/snippets/get-article-title.html11
-rw-r--r--_includes/snippets/get-lang.html6
-rw-r--r--_includes/snippets/get-locale-string.html12
-rw-r--r--_includes/snippets/get-nav-url.html8
-rw-r--r--_includes/snippets/get-sources.html2
-rw-r--r--_includes/snippets/get-string-from-locale-config.html7
-rw-r--r--_includes/snippets/is_collection.html6
-rw-r--r--_includes/snippets/page-url.html2
-rw-r--r--_includes/snippets/prepend-baseurl.html4
-rw-r--r--_includes/snippets/prepend-path.html1
11 files changed, 68 insertions, 0 deletions
diff --git a/_includes/snippets/assign.html b/_includes/snippets/assign.html
new file mode 100644
index 0000000..c2691f5
--- /dev/null
+++ b/_includes/snippets/assign.html
@@ -0,0 +1,9 @@
+{%- if include.source1 == nil -%}
+ {%- if include.source0 == nil -%}
+ {%- assign __return = include.target -%}
+ {%- else -%}
+ {%- assign __return = include.source0 -%}
+ {%- endif -%}
+{%- else -%}
+ {%- assign __return = include.source1 -%}
+{%- endif -%}
diff --git a/_includes/snippets/get-article-title.html b/_includes/snippets/get-article-title.html
new file mode 100644
index 0000000..395b793
--- /dev/null
+++ b/_includes/snippets/get-article-title.html
@@ -0,0 +1,11 @@
+{%- assign _title = include.article.title | default: layout.title -%}
+{%- assign _titles = include.article.titles | default: layout.titles -%}
+
+{%- if _title -%}
+ {%- assign __return = _title -%}
+{%- elsif _titles -%}
+ {%- include snippets/get-string-from-locale-config.html locale=_titles -%}
+ {%- assign __return = __return -%}
+{%- else -%}
+ {%- assign __return = nil -%}
+{%- endif -%}
diff --git a/_includes/snippets/get-lang.html b/_includes/snippets/get-lang.html
new file mode 100644
index 0000000..028c52a
--- /dev/null
+++ b/_includes/snippets/get-lang.html
@@ -0,0 +1,6 @@
+{%- assign __return = site.data.variables.default.lang -%}
+{%- if page.lang -%}
+ {%- assign __return = page.lang -%}
+{%- elsif site.lang -%}
+ {%- assign __return = site.lang -%}
+{%- endif -%}
diff --git a/_includes/snippets/get-locale-string.html b/_includes/snippets/get-locale-string.html
new file mode 100644
index 0000000..a7069ae
--- /dev/null
+++ b/_includes/snippets/get-locale-string.html
@@ -0,0 +1,12 @@
+{%- include snippets/get-lang.html -%}
+{%- assign _lang = __return -%}
+{%- assign _local_lang = site.data.locale[_lang] -%}
+{%- assign _local_lang_en = site.data.locale.en -%}
+{%- if _local_lang == nil -%}
+ {%- assign _local_lang = _local_lang_en -%}
+{%- endif -%}
+{%- if _local_lang[include.key] -%}
+ {%- assign __return = _local_lang[include.key] -%}
+{%- else -%}
+ {%- assign __return = _local_lang_en[include.key] -%}
+{%- endif -%}
diff --git a/_includes/snippets/get-nav-url.html b/_includes/snippets/get-nav-url.html
new file mode 100644
index 0000000..3b1b122
--- /dev/null
+++ b/_includes/snippets/get-nav-url.html
@@ -0,0 +1,8 @@
+{%- assign _pre7 = include.path | slice: 0, 7 -%}
+{%- assign _pre8 = include.path | slice: 0, 8 -%}
+{%- if _pre7 == 'http://' or _pre8 == 'https://' -%}
+ {%- assign __return = include.path -%}
+{%- else -%}
+ {%- include snippets/prepend-baseurl.html path=include.path -%}
+ {%- assign __return = __return -%}
+{%- endif -%}
diff --git a/_includes/snippets/get-sources.html b/_includes/snippets/get-sources.html
new file mode 100644
index 0000000..0de1cb5
--- /dev/null
+++ b/_includes/snippets/get-sources.html
@@ -0,0 +1,2 @@
+{%- assign _sources = site.sources | default: site.data.variables.default.sources -%}
+{%- assign __return = site.data.variables.sources[_sources] -%}
diff --git a/_includes/snippets/get-string-from-locale-config.html b/_includes/snippets/get-string-from-locale-config.html
new file mode 100644
index 0000000..03325fa
--- /dev/null
+++ b/_includes/snippets/get-string-from-locale-config.html
@@ -0,0 +1,7 @@
+{%- include snippets/get-lang.html -%}
+{%- assign _lang = __return -%}
+{%- if include.locale[_lang] -%}
+ {%- assign __return = include.locale[_lang] -%}
+{%- else -%}
+ {%- assign __return = include.locale.en -%}
+{%- endif -%}
diff --git a/_includes/snippets/is_collection.html b/_includes/snippets/is_collection.html
new file mode 100644
index 0000000..559a624
--- /dev/null
+++ b/_includes/snippets/is_collection.html
@@ -0,0 +1,6 @@
+{%- assign _page_path_first_char = include.page.path | slice: 0, 1 -%}
+{%- if _page_path_first_char == '_' -%}
+ {%- assign __return = true -%}
+{%- else -%}
+ {%- assign __return = false -%}
+{%- endif -%}
diff --git a/_includes/snippets/page-url.html b/_includes/snippets/page-url.html
new file mode 100644
index 0000000..3e9815d
--- /dev/null
+++ b/_includes/snippets/page-url.html
@@ -0,0 +1,2 @@
+{%- include snippets/prepend-baseurl.html path=page.url -%}
+{{ __return | prepend: site.url }} \ No newline at end of file
diff --git a/_includes/snippets/prepend-baseurl.html b/_includes/snippets/prepend-baseurl.html
new file mode 100644
index 0000000..d5d24ef
--- /dev/null
+++ b/_includes/snippets/prepend-baseurl.html
@@ -0,0 +1,4 @@
+{%- assign _include_path_replace_index = include.path | replace: 'index.html', '' -%}
+{%- include snippets/prepend-path.html
+ path=_include_path_replace_index
+ prepend_path=site.baseurl -%} \ No newline at end of file
diff --git a/_includes/snippets/prepend-path.html b/_includes/snippets/prepend-path.html
new file mode 100644
index 0000000..5f6e904
--- /dev/null
+++ b/_includes/snippets/prepend-path.html
@@ -0,0 +1 @@
+{%- assign __return = include.path | prepend: '/' | prepend: include.prepend_path | replace:'///','/' | replace:'//','/' -%}