66*/
77
88import { info } from "log/mod.ts" ;
9- import { join , relative } from "path/mod.ts" ;
9+ import { dirname , join , relative } from "path/mod.ts" ;
1010import { copy , existsSync } from "fs/mod.ts" ;
1111import * as colors from "fmt/colors.ts" ;
1212
1313import { Confirm } from "cliffy/prompt/confirm.ts" ;
1414
1515import { removeIfExists , which } from "../../core/path.ts" ;
1616import { execProcess } from "../../core/process.ts" ;
17- import { projectContext } from "../../project/project-context.ts" ;
1817
19- import { kProjectOutputDir , ProjectContext } from "../../project/types.ts" ;
18+ import { ProjectContext } from "../../project/types.ts" ;
2019import {
2120 AccountToken ,
2221 anonymousAccount ,
@@ -28,6 +27,7 @@ import { shortUuid } from "../../core/uuid.ts";
2827import { sleep } from "../../core/wait.ts" ;
2928import { joinUrl } from "../../core/url.ts" ;
3029import { completeMessage , withSpinner } from "../../core/console.ts" ;
30+ import { renderForPublish } from "../common/publish.ts" ;
3131
3232export const kGhpages = "gh-pages" ;
3333const kGhpagesDescription = "GitHub Pages" ;
@@ -36,7 +36,6 @@ export const ghpagesProvider: PublishProvider = {
3636 name : kGhpages ,
3737 description : kGhpagesDescription ,
3838 requiresServer : false ,
39- canPublishDocuments : false ,
4039 listOriginOnly : false ,
4140 accountTokens,
4241 authorizeToken,
@@ -96,14 +95,17 @@ function resolveTarget(
9695
9796async function publish (
9897 _account : AccountToken ,
99- _type : "document" | "site" ,
98+ type : "document" | "site" ,
10099 input : string ,
101- _title : string ,
100+ title : string ,
102101 _slug : string ,
103102 render : ( siteUrl ?: string ) => Promise < PublishFiles > ,
104103 options : PublishOptions ,
105- _target ?: PublishRecord ,
104+ target ?: PublishRecord ,
106105) : Promise < [ PublishRecord | undefined , URL | undefined ] > {
106+ // convert input to dir if necessary
107+ input = Deno . statSync ( input ) . isDirectory ? input : dirname ( input ) ;
108+
107109 // get context
108110 const ghContext = await gitHubContext ( input ) ;
109111
@@ -143,12 +145,13 @@ async function publish(
143145 ] ) ;
144146
145147 // render
146- const project = ( await projectContext ( input ) ) ! ;
147- const outputDir = project . config ?. project [ kProjectOutputDir ] ;
148- if ( outputDir === undefined ) {
149- throwUnableToPublish ( "no output-dir defined for project" ) ;
150- }
151- const renderResult = await render ( ghContext . siteUrl ) ;
148+ const renderResult = await renderForPublish (
149+ render ,
150+ "gh-pages" ,
151+ type ,
152+ title ,
153+ target ?. url ,
154+ ) ;
152155
153156 // allocate worktree dir
154157 const tempDir = Deno . makeTempDirSync ( { dir : input } ) ;
0 commit comments