Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/thenewdynamic/hugo-module-tnd-menus

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/thenewdynamic/hugo-module-tnd-menus

  • v0.0.0-20210322205111-03cfde5da487
  • Source
  • Go
  • Socket score

Version published
Created
Source

This is a template repo. To start.

search TND Nav through the project and replace it with the module identifier (ex: socials for hugo-module-tnd-socials)

Nav Hugo Module

(intro)

Requirements

Requirements:

  • Go 1.14
  • Hugo 0.64.0

Installation

If not already, init your project as Hugo Module:

$: hugo mod init {repo_url}

Configure your project's module to import this module:

# config.yaml
module:
  imports:
  - path: github.com/theNewDynamic/hugo-module-tnd-menus

Setting Menus

The menus are set following Hugo's own ways.

On top of that, if you're using Hugo 0.79.0 and above, it's possible to set a Page to a Menu Entry with the project's configuration method. Simple add a page params whose value would find a page in your content directory following the site.GetPage API.

Ex:

# config/_default/menus.yaml
main:
- name: About
  params:
    page: /about
- name: History
  params:
    page: /posts/a-brief-history

Usage

tnd-menus/GetMenu

Anywhere in your templates you can invoke the tnd-menus/GetMenu partial. Its context expect either:

  • A Map with:
    • menu* holds a string pointing to the menu key as used in your project. (Ex: "main").
    • Page, a Hugo Page which will set as the current page when using IsActive. If not set, we'll use the Homepage.
  • A String pointing holding the pointing to the menu key as used in your project. (Ex: "main"). The Homepage will be used as Page.
Examples
{{ $args := dict "menu" "main" "Page" $ }}
{{ range partial "tnd-menus/GetMenu" $args }}
  <a href="{{ .URL }}" class="MenuItem {{ if .Active }} MenuItem--active {{ end }}"
  {{ if .External }} target="_blank"{{ end }}>
  {{ .Name }}
  </a>
  {{ with .Children }}
  {{/* ... */}}
  {{ end }}
{{ end }}

The Module's Menu Entry object

Any given entry returned by the tnd-menus/GetMenu partial will hold the following keys: Warning: Case matters.

  • Name: Menu Entry name of the Menu Entry
  • URL: Menu Entry URL
  • External (Bool): Is the MenuEntry URL external.
  • Active (Bool): BIs the MenuEntry considered active given the module's default or users's IsActive partial
  • Page (Page): The page associated with the MenuEntry if set.
  • Level (Int): The hierarchy Level of the Menu Entry in the given menu. Starts at 1.
  • Children (Slice of maps): A list of Menu Entries following hereby data structure.
  • ... Any other lowercase key will be a key found in the Menu Entry's params map.

Settings

Settings are added to the project's parameter under the tnd_nav map as shown below.

# config.yaml
params:
  tnd_nav:
    [...]
Configure Key 1
Configure Key 2
Defaults

ld copy/paste the above to your settings and append with new extensions.

theNewDynamic

This project is maintained and loved by thenewDynamic.

FAQs

Package last updated on 22 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc