forked from theme-next/hexo-theme-next
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request theme-next#156 from theme-next/sub-menu-feature
Added sub-menu feature.
- Loading branch information
Showing
11 changed files
with
229 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% macro render(value) %} | ||
<li class="menu-item menu-item-{{ itemName | replace(' ', '-', 'g') }}"> | ||
<a href="{{ url_for(value.split('||')[0]) | trim }}" rel="section"> | ||
{% if theme.menu_settings.icons %}{# | ||
#}<i class="menu-item-icon fa fa-fw fa-{{ value.split('||')[1] | trim | default('question-circle') }}"></i> <br />{# | ||
#}{% endif %}{# | ||
#}{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{% macro render(name, value) %}{# | ||
#}{% if theme.menu_settings.badges %}{# | ||
#}{% if name == 'archives' %}{# | ||
#}{{ __('menu.' + name) | replace('menu.', '') }}{# | ||
#}<span class="badge">{{ site.posts.length }}</span> | ||
{% elseif name == 'categories' %}{# | ||
#}{{ __('menu.' + name) | replace('menu.', '') }}{# | ||
#}<span class="badge">{{ site.categories.length }}</span> | ||
{% elseif name == 'tags' %}{# | ||
#}{{ __('menu.' + name) | replace('menu.', '') }}{# | ||
#}<span class="badge">{{ site.tags.length }}</span> | ||
{% else %}{# | ||
#}{% if value != '[object Object]' %}{# | ||
#}{{ __('menu.' + name) | replace('menu.', '') }}{# | ||
#}{% endif %}{# | ||
#}{% endif %}{# | ||
#}{% else %}{# | ||
#}{% if value != '[object Object]' %}{# | ||
#}{{ __('menu.' + name) | replace('menu.', '') }}{# | ||
#}{% endif %}{# | ||
#}{% endif %}{# | ||
|
||
#}</a> | ||
</li> | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% macro render(name, value) %} | ||
<li class="menu-item menu-item-{{ itemName | replace(' ', '-', 'g') }}"> | ||
<a href="{{ url_for(value.split('||')[0]) | trim }}" rel="section"> | ||
{% if theme.menu_settings.icons %}{# | ||
#}<i class="menu-item-icon fa fa-fw fa-{{ value.split('||')[1] | trim | default('question-circle') }}"></i> <br />{# | ||
#}{% endif %}{# | ||
#}{{ __('menu.' + name ) | replace('menu.', '') }}{# | ||
#}</a> | ||
</li> | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
{% if not is_home() && not is_post() %} | ||
{% if theme.menu %} | ||
|
||
{% import '../_macro/menu/menu-item.swig' as menu_item %} | ||
|
||
{# Submenu & Submenu-2 #} | ||
{% for name, value in theme.menu %} | ||
{% set respath = value %} | ||
{% if value == '[object Object]' %} | ||
|
||
{# If current URL is value of parent submenu 'default' path #} | ||
{% set currentParentUrl = page.path.split('/')[0] | trim %} | ||
{% if currentParentUrl == value.default.split('||')[0] | trim | replace('/', '', 'g') %} | ||
|
||
{# Submenu items #} | ||
<ul id="sub-menu" class="sub-menu menu"> | ||
{% for subname, subvalue in value %} | ||
{# For main submenu items #} | ||
{% if subvalue != '[object Object]' %} | ||
{% set itemName = subname.toLowerCase() %} | ||
{% if itemName == 'default' %} | ||
{% set parentValue = subvalue.split('||')[0] | trim %} | ||
{% else %} | ||
{% set respath = parentValue + subvalue %} | ||
{{ menu_item.render(subname, respath) }} | ||
{% endif %} | ||
{% else %} | ||
{# For 'default' submenu item in main submenu #} | ||
{% set itemName = subname.toLowerCase() %} | ||
{% for subname2, subvalue2 in subvalue %} | ||
{% if subname2 == 'default' %} | ||
{% set respath = parentValue + subvalue2 %} | ||
{{ menu_item.render(subname, respath) }} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
{% endfor %} | ||
</ul> | ||
{# End Submenu items #} | ||
|
||
{# Submenu-2 #} | ||
{% for name, value in theme.menu %} | ||
{% set respath = value %} | ||
{% if value == '[object Object]' %} | ||
|
||
{% for subname, subvalue in value %} | ||
{% set itemName = subname.toLowerCase() %} | ||
{% if itemName == 'default' %} | ||
{% set parentValue = subvalue.split('||')[0] | trim %} | ||
{% endif %} | ||
{% if subvalue == '[object Object]' %} | ||
|
||
{# If current URL is value of parent submenu 'default' path #} | ||
{% set paths = page.path.split('/') %} | ||
{% for currentSubParentUrl in paths %} | ||
{% if currentSubParentUrl == subvalue.default.split('||')[0] | trim | replace('/', '', 'g') %} | ||
|
||
{# Submenu-2 items #} | ||
<ul id="sub-menu-2" class="sub-menu menu"> | ||
{% for subname2, subvalue2 in subvalue %} | ||
{% set respath2 = subvalue %} | ||
{% set itemName = subname2.toLowerCase() %} | ||
{% if itemName == 'default' %} | ||
{% set parentSubValue = subvalue2.split('||')[0] | trim %} | ||
{% else %} | ||
{% set respath2 = parentValue + parentSubValue + subvalue2 %} | ||
{{ menu_item.render(subname2, respath2) }} | ||
{% endif %} | ||
{% endfor %} | ||
</ul> | ||
{# End Submenu-2 items #} | ||
|
||
{% endif %} | ||
{% endfor %} | ||
{# End URL & path comparing #} | ||
|
||
{% endif %} | ||
{% endfor %} | ||
|
||
{% endif %} | ||
{% endfor %} | ||
{# End Submenu-2 #} | ||
|
||
{% endif %} | ||
{# End URL & path comparing #} | ||
|
||
{% endif %} | ||
{% endfor %} | ||
{# End Submenu & Submenu-2 #} | ||
|
||
{% endif %} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
} | ||
|
||
.menu { | ||
float: right; | ||
//float: right; | ||
margin: 8px 0 0 0; | ||
|
||
+mobile() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.sub-menu { | ||
margin: 0; | ||
padding: 6px 0; | ||
background: #fff !important; | ||
border-bottom: 1px solid $table-border-color; | ||
} | ||
|
||
.sub-menu .menu-item { | ||
display: inline-block !important; | ||
|
||
& a { | ||
padding: initial !important; | ||
margin: 5px 10px; | ||
} | ||
|
||
& a:hover { | ||
background: initial !important; | ||
color: $sidebar-highlight; | ||
} | ||
} | ||
|
||
.sub-menu .menu-item-active a { | ||
background: #fff !important; | ||
color: $sidebar-highlight; | ||
border-bottom-color: $sidebar-highlight; | ||
|
||
&:hover { | ||
background: #fff !important; | ||
border-bottom-color: $sidebar-highlight; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
@import "_layout"; | ||
@import "_brand"; | ||
@import "_menu"; | ||
@import "_sub-menu"; | ||
@import "_sidebar"; | ||
@import "_posts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters