@@ -56,32 +56,35 @@ export async function onPostBuild({ graphql, pathPrefix = "" }, pluginOptions) {
56
56
const userOptions = getOptions ( pluginOptions ) ;
57
57
const mergedOptions = { ...defaultOptions , ...userOptions } ;
58
58
59
- if (
60
- ! Object . prototype . hasOwnProperty . call ( mergedOptions , 'host' )
61
- ) {
62
- const {
63
- site : {
64
- siteMetadata : { siteUrl }
65
- }
66
- } = await runQuery ( graphql , mergedOptions . query ) ;
67
-
68
- mergedOptions . host = siteUrl ;
59
+ if ( mergedOptions . host !== null ) {
60
+ if (
61
+ ! Object . prototype . hasOwnProperty . call ( mergedOptions , 'host' )
62
+ ) {
63
+ const {
64
+ site : {
65
+ siteMetadata : { siteUrl }
66
+ }
67
+ } = await runQuery ( graphql , mergedOptions . query ) ;
68
+
69
+ mergedOptions . host = siteUrl ;
70
+ }
69
71
}
70
72
71
- if (
72
- ! Object . prototype . hasOwnProperty . call ( mergedOptions , 'sitemap' )
73
- ) {
74
-
75
- mergedOptions . sitemap = new URL ( path . posix . join ( pathPrefix , 'sitemap' , 'sitemap-index.xml' ) , mergedOptions . host ) . toString ( ) ;
76
- } else {
77
- try {
78
- new URL ( mergedOptions . sitemap )
79
- } catch {
80
- mergedOptions . sitemap = new URL ( mergedOptions . sitemap . startsWith ( pathPrefix ) ? mergedOptions . sitemap : path . posix . join ( pathPrefix , mergedOptions . sitemap ) , mergedOptions . host ) . toString ( )
73
+ if ( mergedOptions . sitemap !== null ) {
74
+ if (
75
+ ! Object . prototype . hasOwnProperty . call ( mergedOptions , 'sitemap' )
76
+ ) {
77
+
78
+ mergedOptions . sitemap = new URL ( path . posix . join ( pathPrefix , 'sitemap' , 'sitemap-index.xml' ) , mergedOptions . host ) . toString ( ) ;
79
+ } else {
80
+ try {
81
+ new URL ( mergedOptions . sitemap )
82
+ } catch {
83
+ mergedOptions . sitemap = new URL ( mergedOptions . sitemap . startsWith ( pathPrefix ) ? mergedOptions . sitemap : path . posix . join ( pathPrefix , mergedOptions . sitemap ) , mergedOptions . host ) . toString ( )
84
+ }
81
85
}
82
86
}
83
87
84
-
85
88
const { policy, sitemap, host, output, configFile } = mergedOptions ;
86
89
87
90
const content = await robotsTxt ( {
0 commit comments