Section menu for the lazy blogger

The current menu system works great, but is too much work if all you want is a simple menu with the sections as menu items, and having these menu items connected to the pages in a way that enables setting the correct menu item as active for both the section lists and the pages itself.

This commit adds a new option `SectionPagesMenu' which, if set, will create a new menu with that name with all the sections as menu items. The pages in the sections will behave as "shadow members" of these section items as `blogpage.HasMenuCurrent "sectionmenu" $sectionmenuitem` will return true.

If a menu item with the same `identifier` is defined in site config, *that* item will take precedence.
This commit is contained in:
bep
2015-01-06 18:11:06 +01:00
committed by spf13
parent beb4ab162d
commit d4acacd4f5
4 changed files with 35 additions and 4 deletions

View File

@@ -11,6 +11,7 @@ import (
"github.com/spf13/hugo/source"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"path/filepath"
)
const (
@@ -90,9 +91,15 @@ weight = 3
Front Matter with Menu Pages`)
var MENU_PAGE_SOURCES = []source.ByteSource{
{"sect/doc1.md", MENU_PAGE_1},
{"sect/doc2.md", MENU_PAGE_2},
{"sect/doc3.md", MENU_PAGE_3},
{filepath.FromSlash("sect/doc1.md"), MENU_PAGE_1},
{filepath.FromSlash("sect/doc2.md"), MENU_PAGE_2},
{filepath.FromSlash("sect/doc3.md"), MENU_PAGE_3},
}
var MENU_PAGE_SECTIONS_SOURCES = []source.ByteSource{
{filepath.FromSlash("first/doc1.md"), MENU_PAGE_1},
{filepath.FromSlash("first/doc2.md"), MENU_PAGE_2},
{filepath.FromSlash("second-section/doc3.md"), MENU_PAGE_3},
}
func tstCreateMenuPageWithNameTOML(title, menu, name string) []byte {