npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kiwigrid/antora-main-menu

v1.1.0

Published

Antora 3 extension to generate a dynamic main menu.

Downloads

192

Readme

GitHub release (latest SemVer) npm (scoped) npm

antora-menu-extension

Antora 3 extension to assemble customized main menu

The extension allows Antora to build a customizable main menu structure composing handlebar templates provided by the UI resources.

domain.png

The used UI templates are configurable at the extension to allow theming and styling within the UI resources as usual.

Usage

Make sure the handlebar templates are available within your UI resources specified in the playbook

npm i @kiwigrid/antora-main-menu
...
ui:
  bundle:
    url: ..../ui-bundle.zip
ui-bundle.zip
    \-- partials
        |-- ....
        |-- your templates.hbs
        \-- ....

Link the menu template within the menu bar handlebar template (usually header-content.hbs).

....
{{> main-menu}}
....

Then add the extension to your playbook:

antora:
  extensions:
    - require: "@kiwigrid/antora-main-menu"
      menu: <menu structure definition>
      hbs: <UI template customization>

Menu Structure

The menu structure may be defined inline within the extension configuration or as dedicated resource within any antora component referenced within the playbook.

  1. dedicated resource
antora:
  extensions:
    - require: "@kiwigrid/antora-main-menu"
      component: <component reference>
      file: <resource within component>
  1. inline definition
antora:
  extensions:
    - require: "@kiwigrid/antora-main-menu"
      menu: <definition>

The definition and the dedicated component resource are following the same schema:

A menu definition consists of a list if of menu groups, component references and/or external links.

A group is defined as:

- title: <group display text>
  entries: 
      - <nested element 1>
      - ...
      - <nested element n>

Nested elements may be groups (again), component references and/or external links.

A component reference is defined as:

- module: <moduleId>

An external link is defined as:

- title: <link display tex>
  link: <target url>

Example menu

antora:
  extensions:
    - require: "@kiwigrid/antora-main-menu"
      menu:
        - title: Products
          entries:
            - module: product-A
            - title: Product Sub 1
              entries:
                - module: product-B
        - title: Help
          entries:
            - title: Antora Documentation
              link: https://docs.antora.org
            - title: Configure this extension
              link: https://github.com/kiwigrid/antora-menu-extension

UI Template Customization

The extension creates a handlebar template based on the given playbook parameter and adds the template into the UI catalog for site rendering.

The created template itself is composed on templates provided by the UI resource you are referring in the playbook.

ui:
  bundle:
    url: ..../ui-bundle.zip

The template itself are used to apply the menu rendering and theming.

The extension expects the following templates:

  • Main template:
    • the template name to create and add into the template catalog
  • Group beginning template:
    • the template to begin a list of menu entries
  • Group end template:
    • the template to close a list of menu entries
  • Document reference template
    • A link to a site internal or external url.

The template names may be customized via extension config.

antora:
  extensions:
    - require: "@kiwigrid/antora-main-menu"
      hbs: 
        menu: <Main template>                         # default main-menu
        group_start: <Group beginning template>       # default main-menu-group-start
        group_end: <Group end template>               # default main-menu-group-end
        document_ref: <Document reference template>   # default main-menu-docref

The templates are supporting the following parameter:

  • main-menu: No parameter
  • main-menu-group-end: No parameter

main-menu-group-start

  • level
    • Nesting level of the menu group to begin. (0 == main menu, 1...n nesting level)
  • group_title
    • Menu group text

main-menu-docref

  • resolved
    • Exposing, if the module of the menu specification item could be resolved through the playbooks included module sources.
    • The doc_title contains in that case the name value from the modules antora.yml field.
  • external
    • Exposing, if the ref links to a site external target URL
  • doc_title
    • Menu entry text, if the ref could be resolved, or the name of the module that couldn't be resolved.
  • ref
    • Resolvable (either absolute or relative to playbook base) document URI.
    • The parameter contains #, if the parameter resolved is marked false.
  • component
    • the components name (from antory.yml), if resolved, or null for unresolved module references and external links.

Sample

Given the extension config uses the standard templates and inline menu definition:

antora:
  extensions:
    - require: "@kiwigrid/antora-main-menu"
      menu:
        - title: Products
          entries:
            - title: sub group
              entries:
                - module: existing-module
                - module: not-existing-module
                - title: Antora Doc
                  link: https://docs.antora.org

The template main-menu is created by the extension as:

{{> main-menu-group-start level=0 group_title="Products"}}
    {{> main-menu-group-start level=1 group_title="sub group"}}
        {{> main-menu-docref resolved=true external=false ref="/existing-module/latest/<startpage of existing-module>.html" doc_title="<Title of existing-module>" component="<name of existing-module>"}}
        {{> main-menu-docref resolved=false external=false ref="#" doc_title="not-existing-module" component="null"}}
        {{> main-menu-docref resolved=true external=true ref="https://docs.antora.org" doc_title="Antora Doc"}}
    {{> main-menu-group-end}}
{{> main-menu-group-end}}

Find sample templates in templates or ui-examples folder.