### Context
-The context is referenced for authenticated user information, as well as messaging.
-
-- `ctx.session.authenticatedIdentifier`
-- `ctx.session.authenticatedProfile`
-
-If either of these are present, navigation links are added to the page header allowing the user to manage their account or log out.
-The links will point relatively to `/admin/settings` and `/admin/logout`, respectively.
-
-- `ctx.url`
-
-If present, added as a query parameter (`r`, for redirect) to the logout link.
-
- `ctx.errors`
- `ctx.notifications`
/**
- * Render all parts of an HTML page. Adds user logout nav link automatically.
+ * Render all parts of an HTML page.
* @param {Number} pagePathLevel - relative path-distance to base
* @param {Object} ctx
- * @param {Object=} ctx.session
- * @param {String=} ctx.session.authenticatedIdentifier
- * @param {String=} ctx.session.authenticatedProfile
* @param {String[]=} ctx.errors
* @param {String[]=} ctx.notifications
* @param {Object} options
* @returns {String}
*/
function htmlPage(pagePathLevel, ctx, options, main = []) {
- const user = ctx?.session?.authenticatedProfile || ctx?.session?.authenticatedIdentifier;
- if (user) {
- if (!options.navLinks) {
- options.navLinks = [];
- }
- const logoutRedirect = ctx?.url ? `?r=${encodeURIComponent(ctx.url)}` : '';
- const adminPath = (pagePathLevel > 0) ? `${'../'.repeat(pagePathLevel - 1)}` : 'admin/';
- options.navLinks.push({
- text: 'Account',
- href: `${adminPath}settings`,
- }, {
- text: `Logout (${user})`,
- href: `${adminPath}logout${logoutRedirect}`,
- });
- }
-
return [
'<!DOCTYPE html>',
'<html lang="en">',