Added option to use a static or a dynamic list of categories

This commit is contained in:
Javier Rebagliatti 2016-09-16 12:34:01 -03:00
Родитель c25c799346
Коммит f5a040abc9
5 изменённых файлов: 76 добавлений и 13 удалений

Просмотреть файл

@ -7,6 +7,10 @@ url: https://microsoft.github.io" # the base hostname & protocol for your site
twitter_username: dcaro
github_username: microsoft
encoding: utf-8
use_static_category_list: false # true/false: use true to indicate that site will use
# the static category list to build the category tree.
# Use false to indicate the site to build the category
# tree dynamically using the posts' metadata
# Build settings
# markdown: redcarpet

Просмотреть файл

@ -1,16 +1,16 @@
[
{
"name":"Technology",
"name":"technology",
"showAs":"Technology",
"metadataField":"categories"
},
{
"name":"Verticals",
"name":"verticals",
"showAs":"Verticals",
"metadataField":"verticals"
},
{
"name":"Language",
"name":"language",
"showAs":"Language",
"metadataField":"language"
}

Просмотреть файл

@ -0,0 +1,47 @@
[
{
"name":"technology",
"showAs":"Technology",
"metadataField":"categories",
"values":[
"DevOps",
"IoT",
"Mobile Application Development with Xamarin",
"Azure App Service"
]
},
{
"name":"verticals",
"showAs":"Verticals",
"metadataField":"verticals",
"values":[
"Energy",
"Manufacturing (Industrial)",
"Transportation & Logistics",
"Smart Cities",
"Agricultural",
"Environmental",
"Healthcare",
"Financial Services",
"Retail, Consumer Products & Services",
"Communications/Media"
]
},
{
"name":"language",
"showAs":"Language",
"metadataField":"language",
"values":[
"English",
"German",
"Spanish",
"French",
"Italian",
"Japanese",
"Korean",
"Portuguese",
"Russian",
"Chinese"
]
}
]

Просмотреть файл

@ -1,16 +1,28 @@
{% assign useStaticList = site.use_static_category_list %}
{% assign categories = "" | split: "|" %}
{% for category in site.data.categories %}
{% assign categoryElements = "" | split: "|" %}
{% if useStaticList == true %}
{% assign categoriesDataList = site.data.categoriesStatic %}
{% else %}
{% assign categoriesDataList = site.data.categories %}
{% endif %}
{% for post in site.posts %}
{% for category in categoriesDataList %}
{% if useStaticList == true %}
{% assign categoryElements = category.values %}
{% else %}
{% assign categoryElements = "" | split: "|" %}
{% if categoryElements contains post[category.metadataField] %}
{% else %}
{% assign categoryElements = categoryElements | push: post[category.metadataField] %}
{% endif %}
{% for post in site.posts %}
{% endfor %}
{% if categoryElements contains post[category.metadataField] %}
{% else %}
{% assign categoryElements = categoryElements | push: post[category.metadataField] %}
{% endif %}
{% endfor %}
{% endif %}
{% assign categories = categories | push: categoryElements %}
@ -48,7 +60,7 @@
<li>
<input type="checkbox" id="item-{{ category.name }}-{{ item.name }}">
<label>
<input class="search-value" name="Isv{{ category.name }}" type="checkbox" value="{{ item }}">
<input class="search-value" name="{{ category.name }}" type="checkbox" value="{{ item }}">
<span class="treeview-checkbox"></span>
</label>
<label class="remove-tree-control treeview-label" for="idc3c1668c-a145-4316-b84b-aa747027b20f">

Просмотреть файл

@ -119,7 +119,7 @@ var customSearch = (function($){
selectedFilters.{{ category.name }} = {};
selectedFilters.{{ category.name }}.metadataField = '{{ category.metadataField }}';
selectedFilters.{{ category.name }}.values = [];
$.each( $("input[name=Isv{{ category.name }}]:checked"), function(){
$.each( $("input[name={{ category.name }}]:checked"), function(){
selectedFilters.{{ category.name }}.values.push($(this).val());
});
{% endfor %}