Browse Source

Add a base-url flag to the build command

index-subcmd
Vincent Prouillet 7 years ago
parent
commit
73797efe90
5 changed files with 14 additions and 3 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +6
    -0
      docs/content/documentation/getting-started/cli-usage.md
  3. +1
    -0
      src/cli.rs
  4. +4
    -1
      src/cmd/build.rs
  5. +2
    -2
      src/main.rs

+ 1
- 0
CHANGELOG.md View File

@@ -22,6 +22,7 @@
- Defaults to compressed Sass output
- Fix regression wrt co-located assets slug detecting
- Rename `url` from page front-matter to `path` to be consistent
- Add a `base-url` flag to the `build` command to override the URL from config.toml

## 0.1.3 (2017-08-31)



+ 6
- 0
docs/content/documentation/getting-started/cli-usage.md View File

@@ -27,6 +27,12 @@ This will build the whole site in the `public` directory.
$ gutenberg build
```

You can override the config `base_url` by passing a new URL to the `base-url` flag.

```bash
$ gutenberg build --base-url https://59a896e2cf321c2dcfd2d6de--tera.netlify.com/
```

## serve

This will build and serve the site using a local server. You can also specify


+ 1
- 0
src/cli.rs View File

@@ -14,6 +14,7 @@ pub fn build_cli() -> App<'static, 'static> {
)
(@subcommand build =>
(about: "Builds the site")
(@arg base_url: -u --base-url +takes_value "Force the base URL to be that value (default to the one in config.toml)")
)
(@subcommand serve =>
(about: "Serve the site. Rebuild and reload on change automatically")


+ 4
- 1
src/cmd/build.rs View File

@@ -5,8 +5,11 @@ use site::Site;

use console;

pub fn build(config_file: &str) -> Result<()> {
pub fn build(config_file: &str, base_url: Option<&str>) -> Result<()> {
let mut site = Site::new(env::current_dir().unwrap(), config_file)?;
if let Some(b) = base_url {
site.config.base_url = b.to_string();
}
site.load()?;
console::notify_site_size(&site);
console::warn_about_ignored_pages(&site);


+ 2
- 2
src/main.rs View File

@@ -40,10 +40,10 @@ fn main() {
},
};
},
("build", Some(_)) => {
("build", Some(matches)) => {
console::info("Building site...");
let start = Instant::now();
match cmd::build(config_file) {
match cmd::build(config_file, matches.value_of("base_url")) {
Ok(()) => console::report_elapsed_time(start),
Err(e) => {
console::unravel_errors("Failed to build the site", &e);


Loading…
Cancel
Save