update dependencies and devDependencies, address lint issues
[squeep-indie-auther] / src / template / root-html.js
1 'use strict';
2
3 const th = require('./template-helper');
4 const { sessionNavLinks } = require('@squeep/authentication-module');
5
6 /**
7 * @returns {string} section
8 */
9 function aboutSection() {
10 return `
11 <section class="about">
12 <h2>What</h2>
13 <p>
14 This is an <a class="external" href="https://indieweb.org/IndieAuth">IndieAuth</a> service.
15 </p>
16 <p>
17 It facilitates distributed authentication.
18 </p>
19 <p>
20 If you are not an established user of this service, or some sort of web application, there is very little here for you.
21 </p>
22 </section>`;
23 }
24
25 /**
26 * @param {string} contactHTML content
27 * @returns {string} section
28 */
29 function contactSection(contactHTML) {
30 let section = '';
31 if (contactHTML) {
32 section = ` <section>
33 ${contactHTML}
34 </section>`;
35 }
36 return section;
37 }
38
39 /**
40 *
41 * @param {object} ctx context
42 * @param {object} options options
43 * @param {object} options.manager manager options
44 * @param {string} options.manager.pageTitle page title
45 * @param {string[]} options.manager.footerEntries footer entries
46 * @param {string=} options.adminContactHTML content
47 * @returns {string} page
48 */
49 module.exports = (ctx, options) => {
50 const pagePathLevel = 0;
51 const contactHTML = options.adminContactHTML;
52 const htmlOptions = {
53 pageIdentifier: 'root',
54 pageTitle: options.manager.pageTitle,
55 logoUrl: options.manager.logoUrl,
56 footerEntries: options.manager.footerEntries,
57 headElements: [
58 `<link rel="indieauth-metadata" href="${options.dingus.selfBaseUrl}${options.route.metadata}">`,
59 ],
60 };
61 th.navLinks(pagePathLevel, ctx, htmlOptions);
62 sessionNavLinks(pagePathLevel, ctx, htmlOptions);
63 const content = [
64 aboutSection(),
65 contactSection(contactHTML),
66 ];
67 return th.htmlPage(pagePathLevel, ctx, htmlOptions, content);
68 };