import JSONUtils from "../../json" ; import PathUtils from "../../utils/path" ; import Modifiers from "../modifiers" ; import writeFile from "../helper/writeFile" ; import getModifiers from "../getModifiers" ; const JSON_VERSION = "3" ; param { Output } output param { Page } page function onPage ( output , page ) { const file = page . getFile ( ) ; const readme = output . getBook ( ) . getReadme ( ) . getFile ( ) ; return Modifiers . modifyHTML ( page , getModifiers ( output , page ) ) . then ( ( resultPage ) => { const json = JSONUtils . encodeBookWithPage ( output . getBook ( ) , resultPage ) ; delete json . config ; json . version = JSON_VERSION ; let filePath = file . getPath ( ) == readme . getPath ( ) ? "README.json" : file . getPath ( ) ; filePath = PathUtils . setExtension ( filePath , ".json" ) ; return writeFile ( output , filePath , JSON . stringify ( json , null , 4 ) ) ; } ) ; } export { onPage } ;