crisp-oss / chappe

🧑‍💻 Developer Docs builder. Write guides in Markdown and references in API Blueprint. Comes with a built-in search engine.
https://www.npmjs.com/package/chappe
MIT License
206 stars 29 forks source link

add more options to include script #10

Open eliyabar opened 1 year ago

eliyabar commented 1 year ago

Hey, the following use-case was needed for my personal use:

  1. Use an external script
  2. Initialize it with some values.

The existing option is only to create a deferrable script tag. and one more thing, the inline script was rendered before the script tag, for example: this config

...
    "scripts" : {
      "urls"   : ["some link"],
      "inline" : ["init({someArgs})"]
    },
...

will result:

....
    <script>
      init({someArgs})
    </script>
    <script src="some link" defer></script>
...

In my case, the order of the script tag and inline script is reversed. moreover, you can also create a non deferable script tag like so:

...
    "scripts" : {
      "urls"   : [{"url": "https://somescript/index.js", "defer": false}],
      "inline" : []
    },
...

IDK how needed it is, but it helped me :)