import { platform } from 'process' ; import { Platforms } from '../constants' ; import { SinglePageResult } from '../models' ; import { PluginService } from '../services' ; export function generateStaticMarkup ( props , pathToBundle ) { return `
        <!DOCTYPE html>
        <html>
            <head>
                <meta charset="utf-8">
                ${ getMetadata ( props . data . meta ) }
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <title>${ props . data . toc . title }</title>
                <style type="text/css">
                    body {
                        height: 100vh;
                    }
                </style>
                ${ PluginService . getHeadContent ( ) }
            </head>
            <body class="yc-root yc-root_theme_light">
                <div id="root"></div>
                <script type="application/javascript">
                   window.__DATA__ = ${ JSON . stringify ( props ) };
                </script>
                <script type="application/javascript" src="${ pathToBundle }/app.js"></script>
            </body>
        </html>
    ` ; } function getMetadata ( metadata ) { if ( ! metadata ) { return '' ; } const metaEntries = Object . entries ( metadata ) ; return metaEntries . map ( ( [ name , content ] ) => { return `<meta name="${ name }" content="${ content }">` ; } ) . join ( '\n' ) ; } export function joinSinglePageResults ( singlePageResults ) { const delimeter = `${ сarriage }${ сarriage }<hr class="yfm-page__delimeter">${ сarriage }${ сarriage }` ; return singlePageResults . filter ( ( { content } ) => content ) . map ( ( { content } ) => content ) . join ( delimeter ) ; } export function replaceDoubleToSingleQuotes ( str ) { return str . replace ( /"/g , '\'' ) ; } export const сarriage = platform === Platforms . WINDOWS ? '\r\n' : '\n' ;