mirror of
https://github.com/zhigang1992/docz.git
synced 2026-03-27 22:49:33 +08:00
fix(docz-core): templates files
This commit is contained in:
@@ -43,7 +43,7 @@ export interface ICompilerOpts {
|
||||
args: ConfigArgs
|
||||
}
|
||||
|
||||
export interface IConstructorParams<C, S> extends ICompilerOpts {
|
||||
export interface IBundlerConstructor<C, S> extends ICompilerOpts {
|
||||
id: string
|
||||
config: TConfigFn<C>
|
||||
compiler: TCompilerFn<C>
|
||||
@@ -61,14 +61,9 @@ export class Bundler<C = any, S = any> {
|
||||
private compiler: TCompilerFn<C>
|
||||
private server: TServerFn<S>
|
||||
|
||||
constructor({
|
||||
args,
|
||||
constructor(params: IBundlerConstructor<C, S>) {
|
||||
const { args, id, config, compiler, server } = params
|
||||
|
||||
id,
|
||||
config,
|
||||
compiler,
|
||||
server,
|
||||
}: IConstructorParams<C, S>) {
|
||||
this.args = args
|
||||
this.id = id
|
||||
this.config = config
|
||||
|
||||
@@ -17,7 +17,7 @@ const getNameFromDoc = traverseAndAssign<any, string>(
|
||||
path => path.node.arguments[0].value
|
||||
)
|
||||
|
||||
export interface IConstructorParams {
|
||||
export interface IEntryConstructor {
|
||||
file: string
|
||||
src: string
|
||||
}
|
||||
@@ -27,7 +27,7 @@ export class Entry {
|
||||
public filepath: string
|
||||
public route: string
|
||||
|
||||
constructor({ src, file }: IConstructorParams) {
|
||||
constructor({ src, file }: IEntryConstructor) {
|
||||
const ast = convertToAst(file)
|
||||
const name = getNameFromDoc(ast) || ''
|
||||
const srcPath = path.resolve(paths.root, src)
|
||||
|
||||
@@ -14,7 +14,7 @@ const ENV = process.env.NODE_ENV
|
||||
const HOST = process.env.HOST || '0.0.0.0'
|
||||
const PROTOCOL = process.env.HTTPS === 'true' ? 'https' : 'http'
|
||||
|
||||
export interface IConstructorParams {
|
||||
export interface IServerConstructor {
|
||||
port: number
|
||||
theme: string
|
||||
files: string
|
||||
@@ -22,7 +22,7 @@ export interface IConstructorParams {
|
||||
src: string
|
||||
}
|
||||
|
||||
export interface ConfigArgs extends IConstructorParams {
|
||||
export interface ConfigArgs extends IServerConstructor {
|
||||
paths: any
|
||||
env: string
|
||||
host: string
|
||||
@@ -37,7 +37,7 @@ export class Server {
|
||||
private entries: Entries
|
||||
private bundler: Bundler
|
||||
|
||||
constructor(args: IConstructorParams) {
|
||||
constructor(args: IServerConstructor) {
|
||||
const initialArgs = this.getInitialArgs(args)
|
||||
const { port, theme, files, bundler, src, plugins } = load(
|
||||
'playgrodd',
|
||||
@@ -61,7 +61,7 @@ export class Server {
|
||||
})
|
||||
}
|
||||
|
||||
private getInitialArgs(args: IConstructorParams) {
|
||||
private getInitialArgs(args: IServerConstructor) {
|
||||
return pick(['port', 'theme', 'files', 'bundler', 'src'], args)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Theme } from '<%- THEME %>'
|
||||
|
||||
window.__DOCZ_ROUTES__ = <%- ROUTES %>
|
||||
|
||||
const _wrappers = [<%- WRAPPERS %>]
|
||||
const _wrappers = [<% if (WRAPPERS) {%><%- WRAPPERS %><%}%>]
|
||||
|
||||
const recursiveWrappers = ([Wrapper, ...rest], props) => (
|
||||
<Wrapper {...props}>
|
||||
|
||||
@@ -2,8 +2,8 @@ import React from 'react'
|
||||
import { render } from 'react-dom'
|
||||
import { App } from './app'
|
||||
|
||||
const _beforeRenders = [<%- BEFORE_RENDERS %>]
|
||||
const _afterRenders = [<%- AFTER_RENDERS %>]
|
||||
const _beforeRenders = [<% if (BEFORE_RENDERS) {%><%- BEFORE_RENDERS %><%}%>]
|
||||
const _afterRenders = [<% if (AFTER_RENDERS) {%><%- AFTER_RENDERS %><%}%>]
|
||||
|
||||
const beforeRender = () => _beforeRenders.forEach(f => f && f())
|
||||
const afterRender = () => _afterRenders.forEach(f => f && f())
|
||||
|
||||
Reference in New Issue
Block a user