-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: switch to react, apiVersion 2 and newest react components (#448)
- Loading branch information
1 parent
90d7e41
commit 1fbb3ed
Showing
18 changed files
with
22,264 additions
and
4,269 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ test/output | |
output | ||
sample | ||
coverage | ||
__transpiled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// eslint-disable-next-line no-unused-vars | ||
import { AsyncAPIDocumentInterface } from '@asyncapi/parser'; | ||
import { includeFile, generateBase64Favicon, renderSpec, stringifySpec, stringifyConfiguration } from '../helpers/all'; | ||
|
||
/** | ||
* @param {{asyncapi: AsyncAPIDocumentInterface, params: any}} param0 | ||
*/ | ||
export function Index({ asyncapi, params = {} }) { | ||
const favicon = generateBase64Favicon(params); | ||
const renderedSpec = renderSpec(asyncapi, params); | ||
let asyncapiScript = `<script src="js/asyncapi-ui.min.js" type="application/javascript"></script>`; | ||
if(params?.singleFile) { | ||
asyncapiScript = `<script type="text/javascript"> | ||
${includeFile('template/js/asyncapi-ui.min.js')} | ||
</script>`; | ||
} | ||
let styling = `<link href="css/global.min.css" rel="stylesheet"> | ||
<link href="css/asyncapi.min.css" rel="stylesheet">`; | ||
if(params?.singleFile) { | ||
styling = `<style type="text/css"> | ||
${includeFile("template/css/global.min.css")} | ||
${includeFile("template/css/asyncapi.min.css")} | ||
</style>`; | ||
} | ||
let basehref = ''; | ||
if(params.baseHref) { | ||
basehref = `<base href="${params.baseHref}">`; | ||
} | ||
return (`<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
${basehref} | ||
<title>${asyncapi.info().title()} ${asyncapi.info().version()} documentation</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="icon" type="image/x-icon" href="${favicon}" /> | ||
${styling} | ||
</head> | ||
<body> | ||
<div id="root">${renderedSpec}</div> | ||
${asyncapiScript} | ||
<script> | ||
const schema = ${stringifySpec(asyncapi)}; | ||
const config = ${stringifyConfiguration(params)}; | ||
AsyncApiStandalone.hydrate({ schema, config }, document.getElementById("root")); | ||
</script> | ||
</body> | ||
</html>` | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.