Skip to content
Snippets Groups Projects
Commit e314fbb1 authored by Xiao Gui's avatar Xiao Gui
Browse files

chore: quick one pager export raw html

parent dbcc39c7
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@ export class HelpOnePager{
@Optional() pConstService: PureContantService
){
if (pConstService?.backendUrl) {
this.extQuickStarter = `${pConstService.backendUrl}quickstart`
this.extQuickStarter = `quickstart.html`
}
}
}
......@@ -6,13 +6,65 @@ const AngularCompilerPlugin = ngtools.AngularCompilerPlugin
const merge = require('webpack-merge')
const staticAssets = require('./webpack.staticassets')
const compileQuickOnePager = async () => {
const TITLE = 'Interactive Atlas Viewer Quickstart'
const showdown = require('showdown')
const fs = require('fs')
const { promisify } = require('util')
const asyncReadfile = promisify(fs.readFile)
const mdConverter = new showdown.Converter({
tables: true
})
const pathToMd = path.join(__dirname, '../common/helpOnePager.md')
const mdData = await asyncReadfile(pathToMd, 'utf-8')
return `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://unpkg.com/dompurify@latest/dist/purify.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${TITLE}</title>
</head>
<body class="p-4">
</body>
<script>
(() => {
const dirty = \`${mdConverter.makeHtml(mdData).replace(/\`/g, '\\`')}\`
const clean = DOMPurify.sanitize(dirty)
document.body.innerHTML = clean
})()
</script>
</html>
`
}
const outputPath = path.resolve(__dirname,'../dist/aot')
compileQuickOnePager()
.then(html => {
const fs = require('fs')
fs.writeFile(path.join(outputPath, 'quickstart.html'), html, 'utf-8', (err) => {
if (err) throw new Error(`quickOnePager cannot be written to disk`)
})
})
.catch(e => {
console.warn(e)
})
const commonAot = {
entry: {
main: './src/main-aot.ts'
},
output : {
filename : '[name].js',
path : path.resolve(__dirname,'../dist/aot')
path : outputPath
},
module: {
rules: [
......
const merge = require('webpack-merge')
const aotCommon = require('./webpack.aot-common')
const path = require('path')
module.exports = merge(aotCommon, {
mode: 'development',
devtool:'source-map',
devServer: {
contentBase: path.join(__dirname, '../dist/aot/')
}
})
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment