22// load menu options and contacts from content
33const menu = _ .cms (' menu' ) || {}
44const contacts = _ .cms (' contacts' ) || {}
5+
56// some social networks handled by contacts
67const networksWithColors = [
7- [' facebook' , ' #3B5998 ' ],
8- [' youtube' , ' #FF0000 ' ],
9- [' instagram' , ' #E1306C ' ],
10- [' twitter' , ' #1DA1F2 ' ]
8+ [' facebook' , ' #3b5998 ' ],
9+ [' youtube' , ' #ff0000 ' ],
10+ [' instagram' , ' #e1306c ' ],
11+ [' twitter' , ' #1da1f2 ' ]
1112]
13+
1214// start grouping categories by parent slug
1315const allCategories = menu .alphabetical_order
1416 ? _ .lodash .sortBy (_ .categories , [' name' ])
1517 : _ .categories
1618const categoryParents = _ .lodash .groupBy (allCategories, ({ parent }) => {
17- return ! parent || ! parent .slug ? ' _' : parent .slug
19+ return ! parent || ! parent .slug || parent . slug === ' produtos ' ? ' _' : parent .slug
1820})
19- const getSubmenuId = slug => ` a-${ slug .replace (/ \/ / g , ' _' )} `
21+ const getSubmenuId = slug => {
22+ if (slug === ' produtos' ) return ' categories-nav'
23+ return ` a-${ slug .replace (/ \/ / g , ' _' )} `
24+ }
25+
2026const mainCategories = categoryParents ._
2127if (mainCategories) {
2228 if (Array .isArray (menu .sort_categories )) {
@@ -33,6 +39,7 @@ if (mainCategories) {
3339 }
3440}
3541%>
42+
3643<aside id =" menu" class =" menu shadow" >
3744 <nav class =" accordion" id =" accordion-menu" >
3845 <button
@@ -43,6 +50,7 @@ if (mainCategories) {
4350 >
4451 <i class =" i-times" ></i >
4552 </button >
53+
4654 <% for (const slug in categoryParents) { % >
4755 < % if (categoryParents .hasOwnProperty (slug)) { % >
4856 < % let category, parent % >
@@ -58,18 +66,81 @@ if (mainCategories) {
5866 < % } % >
5967 data- parent= " #accordion-menu"
6068 >
61- < div class = " menu__list" >
62- < a href= " /camiseta" class = " menu__item" > Camiseta< / a>
63- < a href= " /camisetas-infantis" class = " menu__item" > Camisetas Infantis< / a>
64- < a href= " /aprenda-se-divertindo" class = " menu__item" > Aprenda se Divertindo< / a>
65- < a href= " /estampas" class = " menu__item" > Estampas< / a>
66- < a href= " /colecoes" class = " menu__item" > Coleções< / a>
67- < a href= " /parceiros" class = " menu__item" > Parceiros< / a>
69+
70+ < % if (slug !== ' _' ) { % >
71+ < % category = _ .categories .find (category => category .slug === slug) % >
72+ < % parent = category && category .parent % >
73+ < button
74+ class = " menu__btn btn"
75+ type= " button"
76+ data- toggle= " collapse"
77+ < % if (! parent || ! parent .slug ) { % >
78+ aria- expanded= " true"
79+ data- target= " #categories-nav"
80+ aria- controls= " categories-nav"
81+ < % } else {
82+ const submenuId = getSubmenuId (parent .slug )
83+ % >
84+ aria- expanded= " false"
85+ data- target= " #<%= submenuId %>"
86+ aria- controls= " <%= submenuId %>"
87+ < % } % >
88+ >
89+ < i class = " i-arrow-left" >< / i>
90+ < / button>
91+ < % } % >
92+
93+ < div class = " menu__list" >
94+ < % categoryParents[slug].forEach ((subcategory , index ) => { % >
95+ < % const hasSubmenu = Array .isArray (categoryParents[subcategory .slug ]) % >
96+ < a
97+ < % if (hasSubmenu) {
98+ const submenuId = getSubmenuId (subcategory .slug )
99+ % >
100+ href= " #<%= submenuId %>"
101+ data- toggle= " collapse"
102+ role= " button"
103+ aria- expanded= " false"
104+ aria- controls= " <%= submenuId %>"
105+ < % } else { % >
106+ href= " /<%= subcategory.slug %>"
107+ < % } % >
108+ id= " c-<%= subcategory._id %>"
109+ class = " menu__item<%- hasSubmenu ? ' has-subcategory' : '' %>"
110+ >
111+ < % if (subcategory .icon ) { % >
112+ < span class = " menu__item-icon" >
113+ < img
114+ data- src= " <%= subcategory.icon.url %>"
115+ alt= " <%= subcategory.icon.alt || subcategory.name %>"
116+ class = " lozad"
117+ data- preload= " <%= (index * 200) %>"
118+ >
119+ < / span>
120+ < % } % >
121+ < span>
122+ < %= subcategory .name % >
123+ < / span>
124+ < % if (hasSubmenu) { % >
125+ < i class = " i-chevron-right" >< / i>
126+ < % } % >
127+ < / a>
128+ < % if (subcategory .slug === ' astronautica' ) { % >
129+ <!-- < a id= " c-exemplo" class = " menu__item" href= " /exemplo" >< span> EXEMPLO < / span>< / a> -->
130+ < % } % >
131+ < % }) % >
68132 < / div>
133+
134+ < % if (category && category .slug ) { % >
135+ < a href= " /<%= category.slug %>" class = " menu__link" >
136+ < %= _ .dictionary (' seeAll$1Category' ).replace (' $1' , category .name ) % >
137+ < / a>
138+ < % } % >
69139 < / div>
70140 < % } % >
71141 < % } %>
72142 </nav >
143+
73144 <footer class =" menu__footer" >
74145 <% if (menu .phone_wpp ) { % >
75146 < div class = " menu__phone" >
@@ -96,6 +167,7 @@ if (mainCategories) {
96167 < % } % >
97168 < / div>
98169 < % } %>
170+
99171 <% if (menu .socials ) { % >
100172 < div class = " menu__social" >
101173 < % networksWithColors .forEach (([network , color ]) => { % >
@@ -115,3 +187,4 @@ if (mainCategories) {
115187 < % } %>
116188 </footer >
117189</aside >
190+
0 commit comments