Skip to content

Commit

Permalink
Feature: enable custom hugo menu (#38)
Browse files Browse the repository at this point in the history
* feat(hugo-plugin): make menu_id configurable

* chore(deps): update lock file

* fix(linter): use camelCase
  • Loading branch information
sebil authored Apr 5, 2022
1 parent 1b5f8b4 commit c85ec57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions packages/cssg-plugin-hugo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const defaultOptions = {
fieldIdMenuEntries: 'entries',
fieldIdMenuHide: 'hide_in_menu',
fieldIdMenuPos: 'menu_pos',
fieldIdMenuId: 'name',
menuRootTypes: ['page', 'folder', 'x-folder'],
typeConfig: {
[TYPE_CONTENT]: ['page'],
Expand Down Expand Up @@ -431,10 +432,10 @@ export default (args) => {
// Automatically build hugo menus
// See https://gohugo.io/content-management/menus/
if (options.typeIdMenu && contentTypeId === options.typeIdMenu) {
const { name = 'main' } = entry.fields;
const menuId = entry.fields[options.fieldIdMenuId];
const menu = await buildMenu(transformContext, runtimeContext, options.menuDepth);

runtimeContext.menus[hugoLocaleCode(locale)][name] = menu;
runtimeContext.menus[hugoLocaleCode(locale)][menuId] = menu;
}

if (type === TYPE_CONTENT) {
Expand Down

0 comments on commit c85ec57

Please sign in to comment.