stoplightio / elements

Build beautiful, interactive API Docs with embeddable React or Web Components, powered by OpenAPI and Markdown.

Home Page:https://stoplight.io/open-source/elements/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Links with absolute urls do not work

manvydasu opened this issue · comments

Hello,

Context

Currently, its impossible to add an absolute url link, which would redirect user from stoplight elements page, to a differente page , which is located outside of stoplight elements scope

Steps to Reproduce

  1. Have @stoplight/elements generated API be placed under specific route, i.e. my-domain.com/api#.
  2. Use hash router.
  3. Have some pages outside of the @stoplight/elements scope, i.e. my-domain.com/guides
  4. Attempt to add a link in API documentation, which would direct user to guides page, i.e. [check out our guides page](/guides)

Current Behavior

The generated links poins to my-domain.com/api#/guides instead of my-domain.com/guides

Expected Behavior

I would expect a valid link to be genrated, which would point to my-domain.com/guides.

Possible Workaround/Solution

No workarounds, unless final host url is known in advance.

  • Version used: Latest @stoplight/elements version

@manvydasu We propose the following enhancement to achieve what you're after:

  1. pick some sort of token to use in the link definition to tell us to put the host in the url (i.e. [check out our guides page]($$origin/guides)
  2. when we come across this token, we'd replace it with the origin where the app is currently hosted

We will work with our Product team to prioritize this, but feel free to put up a PR for the proposed solution above in the meantime.