From db7ab52818cd516652d5c920c6188d86a8b763bf Mon Sep 17 00:00:00 2001 From: "Felix W. Dekker" Date: Mon, 3 May 2021 19:20:54 +0200 Subject: [PATCH] Add callback to reuse fetched nav items Fixes #15. --- package.json | 2 +- src/main/js/main.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 3f91ef3..f21de3c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fwdekker/template", - "version": "2.3.1", + "version": "2.4.0", "description": "The base template for pages on fwdekker.com.", "author": "Felix W. Dekker", "license": "MIT", diff --git a/src/main/js/main.js b/src/main/js/main.js index c86279d..6fd334e 100644 --- a/src/main/js/main.js +++ b/src/main/js/main.js @@ -47,9 +47,10 @@ const doAfterLoad = function(fun) { * Fetches entries asynchronously from the website's API. * * @param [highlightPath] {String} the path to highlight together with its parents + * @param [cb] {Function} the callback to execute on the fetched entries, to prevent the need to re-fetch elsewhere * @returns {HTMLElement} a base navigation element that will eventually be filled with contents */ -const nav = function(highlightPath = "") { +const nav = function(highlightPath = "", cb = undefined) { const base = stringToHtml( `