+/**
+ * Escape some xml things in strings.
+ * @param {string} string string to escape
+ * @returns {string} escaped
+ */
+function xmlEscape(string) {
+ if (typeof string === 'number') {
+ return string;
+ }
+ if (typeof string !== 'string') {
+ return undefined;
+ }
+ // eslint-disable-next-line security/detect-object-injection
+ return string.replace(/[<>&'"]/, (c) => ({
+ '<': '<',
+ '>': '>',
+ '&': '&',
+ '\'': ''',
+ '"': '"',
+ }[c]));
+}
+
+
+/**
+ * Add common site links to navigation header.
+ * @param {number} pagePathLevel depth from root
+ * @param {object} ctx context
+ * @param {object} options options
+ */
+function navLinks(pagePathLevel, ctx, options) {
+ if (!options.navLinks) {
+ options.navLinks = [];
+ }
+ const rootPath = '../'.repeat(pagePathLevel);
+
+ if (options.pageIdentifier !== 'admin') {
+ options.navLinks.push({
+ text: 'Admin',
+ href: `${rootPath}admin/`,
+ });
+ }
+}
+
+