import { isMobile } from './util'
/**
* Render github corner
* @param {Object} data
* @return {String}
*/
export function corner (data) {
if (!data) return ''
if (!/\/\//.test(data)) data = 'https://github.com/' + data
data = data.replace(/^git\+/, '')
return `
`
}
/**
* Render main content
*/
export function main (tpl) {
const aside = `${tpl}`
return (isMobile() ? `${aside}` : `${aside}`) +
`
`
}
/**
* Cover Page
*/
export function cover () {
const SL = ', 100%, 85%'
const bgc = `linear-gradient(to left bottom, hsl(${Math.floor(Math.random() * 255) + SL}) 0%, hsl(${Math.floor(Math.random() * 255) + SL}) 100%)`
return ``
}
export function toggle () {
return ``
}
/**
* Render tree
* @param {Array} tree
* @param {String} tpl
* @return {String}
*/
export function tree (toc, tpl = '') {
if (!toc || !toc.length) return ''
toc.forEach(node => {
tpl += `${node.title}`
if (node.children) {
tpl += ``
}
})
return tpl
}