onury/docma

Script tags are not loaded when loading HTML content

Closed this issue ยท 1 comments

Hello, firstly, thank you for your work. ๐Ÿ‘

The issue is that none of my JS scripts are loaded when I'm trying to load a HTML file to complete my documentation.
For example I am trying to load a demonstration with a bundle.js file (bundled with webpack) in the HTML file:

<div id="demo"></div>
<script type='text/javascript' src='bundle.js'></script>

The docma.json config file:

{
  "debug": 1,
  "clean": true,
  "src": [
    "./src/*.js",
    "./README.md",
    "./examples/demo.html"
  ],
  "serverType": "apache",
  "app": {
    "title": "mytitle",
    "logo": {
      "dark": "/static/img/redc.png"
    },
    "routing": "path",
    "entrance": "content:readme",
    "base": "/"
  },
  "dest": "./examples/documentation/",
  "template": {
    "path": "zebra",
    "options": {
      "title": {
        "label": "mytitle",
        "href": "/"
      },
      "logo": {
        "dark": "/static/img/redc.png",
        "light": "/static/img/redc.png"
      },
      "sidebar": {
        "enabled": true,
        "outline": "tree",
        "collapsed": false,
        "toolbar": true,
        "itemsFolded": false,
        "itemsOverflow": "crop",
        "badges": true,
        "search": true,
        "animations": true
      },
      "symbols": {
        "autoLink": true,
        "params": "list",
        "enums": "list",
        "props": "list",
        "meta": false
      },
      "contentView": {
        "bookmarks": "h1,h2,h3"
      },
      "navbar": {
        "enabled": true,
        "fixed": true,
        "dark": false,
        "animations": true,
        "menu": [
          {
            "label": "Demonstration",
            "href": "/demo"
            }]
          }
        }
      },
      "assets": {
        "/static/img": ["./examples/documentation/img/*.*"]
      }
    }

Output of routes constructed using docma:

Configured SPA Routes:

type     name    path     contentPath          sourceType
-------  ------  -------  -------------------  ----------
api      _def_   /api     โ€”                    js
content  readme  /readme  content/readme.html  md
content  demo    /demo    content/demo.html    html

So accessing the link /demo is not working because scripts are not loaded.
But accessing content into /content/demo.html loads scripts as expected but with a wrong URL script as it expects a /content/bundle.js instead of /bundle.js.

So my question is, are scripts loaded when you are loading HTML files or is this a bug?

Edit: My bundle.js file is available at /bundle.js ;)

onury commented

Hi. It seems you're not copying bundle.js over to your documentation output dir. Can you check the generated output? If this is the case, you can use assets config to copy it to the right path.