@the-starport/nodebb-plugin-mdx-page-renderer 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,7 @@ const sitemapLib = require('./sitemap');
18
18
  const sources = require('./sources');
19
19
  const { resolveLocalPath } = sources;
20
20
  const staticExport = require('./static-export');
21
- const {fixPrefixPath} = require("./utils");
21
+ const {fixPrefixPath, getForumPath} = require("./utils");
22
22
 
23
23
  const user = require.main.require('./src/user');
24
24
  const winston = require.main.require('winston');
@@ -37,11 +37,14 @@ const winston = require.main.require('winston');
37
37
  * @returns {Promise<void>}
38
38
  */
39
39
  async function renderPage(req, res, next) {
40
- // Strip /api prefix if present. ajaxify fetches /api/{path} for SPA navigation
41
- const urlPath = (req.path.startsWith('/api/')
42
- ? req.path.slice(4)
43
- : req.path
44
- )
40
+
41
+ // Strip away forum path from the string
42
+ const forumPath = getForumPath();
43
+ let urlPath = req.path.slice(forumPath.length);
44
+
45
+ if (urlPath.startsWith('/api/')) {
46
+ urlPath = urlPath.slice(4);
47
+ }
45
48
 
46
49
  // Grab the possible sources this route matches
47
50
  const matchingSources = sources.getAll().filter(function (s) {
package/lib/utils.js CHANGED
@@ -1,3 +1,7 @@
1
+ 'use strict';
2
+
3
+ const nconf = require.main.require('nconf');
4
+
1
5
  /**
2
6
  * @param prefix {string} A url prefix
3
7
  * @returns {string} The prefix with a forward slash added to the front, and removed from the end
@@ -15,6 +19,14 @@ const fixPrefixPath = (prefix) => {
15
19
  return prefix;
16
20
  }
17
21
 
22
+ /**
23
+ * @returns {string} The relative path to the forum, e.g. '/forum' or '/'
24
+ */
25
+ const getForumPath = () => {
26
+ return nconf.get('relative_path');
27
+ }
28
+
18
29
  module.exports = {
19
30
  fixPrefixPath,
31
+ getForumPath
20
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-starport/nodebb-plugin-mdx-page-renderer",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Serves MDX-based documentation pages within NodeBB, with server-side rendering and Doxygen API reference components.",
5
5
  "main": "library.js",
6
6
  "repository": {
package/plugin.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "nodebb-plugin-mdx-page-renderer",
3
3
  "name": "MDX Page Renderer",
4
4
  "description": "Serves MDX-based documentation pages within NodeBB with server-side rendering, Doxygen API reference components, and an admin panel for managing content sources.",
5
- "version": "1.0.1",
5
+ "version": "1.0.2",
6
6
  "library": "./library.js",
7
7
  "hooks": [
8
8
  {