Commit aa33ba9 1 parent d99b98d commit aa33ba9 Copy full SHA for aa33ba9
File tree 3 files changed +15
-6
lines changed
3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -71,8 +71,8 @@ pub enum Command {
71
71
force : bool ,
72
72
73
73
/// Changes the base_url
74
- #[ clap( short = 'u' , long, default_value = "127.0.0.1" ) ]
75
- base_url : String ,
74
+ #[ clap( short = 'u' , long) ]
75
+ base_url : Option < String > ,
76
76
77
77
/// Include drafts when loading the site
78
78
#[ clap( long) ]
Original file line number Diff line number Diff line change @@ -325,17 +325,26 @@ fn create_new_site(
325
325
interface_port : u16 ,
326
326
output_dir : Option < & Path > ,
327
327
force : bool ,
328
- base_url : & str ,
328
+ base_url : Option < & str > ,
329
329
config_file : & Path ,
330
330
include_drafts : bool ,
331
- no_port_append : bool ,
331
+ mut no_port_append : bool ,
332
332
ws_port : Option < u16 > ,
333
333
) -> Result < ( Site , SocketAddr ) > {
334
334
SITE_CONTENT . write ( ) . unwrap ( ) . clear ( ) ;
335
335
336
336
let mut site = Site :: new ( root_dir, config_file) ?;
337
337
let address = SocketAddr :: new ( interface, interface_port) ;
338
338
339
+ // if no base URL provided, use socket address
340
+ let base_url = base_url. map_or_else (
341
+ || {
342
+ no_port_append = true ;
343
+ address. to_string ( )
344
+ } ,
345
+ |u| u. to_string ( ) ,
346
+ ) ;
347
+
339
348
let base_url = if base_url == "/" {
340
349
String :: from ( "/" )
341
350
} else {
@@ -385,7 +394,7 @@ pub fn serve(
385
394
interface_port : u16 ,
386
395
output_dir : Option < & Path > ,
387
396
force : bool ,
388
- base_url : & str ,
397
+ base_url : Option < & str > ,
389
398
config_file : & Path ,
390
399
open : bool ,
391
400
include_drafts : bool ,
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ fn main() {
106
106
port,
107
107
output_dir. as_deref ( ) ,
108
108
force,
109
- & base_url,
109
+ base_url. as_deref ( ) ,
110
110
& config_file,
111
111
open,
112
112
drafts,
You can’t perform that action at this time.
0 commit comments