From 4f418a11b4f3a49a92043207f51bf87b79dd7c32 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Sun, 5 Aug 2018 10:29:53 +0200 Subject: [PATCH] Fix live reload of section content --- CHANGELOG.md | 6 +++++- components/rebuild/src/lib.rs | 5 +++++ docs/content/documentation/getting-started/cli-usage.md | 8 ++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f304847..5801d1a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog -## 0.4.0 (unreleased) +## 0.4.1 (unreleased) + +- Fix live reload of a section content change getting no data + +## 0.4.0 (2018-08-4) ### Breaking diff --git a/components/rebuild/src/lib.rs b/components/rebuild/src/lib.rs index a96c7fb0..fb47eaec 100644 --- a/components/rebuild/src/lib.rs +++ b/components/rebuild/src/lib.rs @@ -136,6 +136,11 @@ fn handle_section_editing(site: &mut Site, path: &Path) -> Result<()> { match site.add_section(section, true)? { // Updating a section Some(prev) => { + // Copy the section data so we don't end up with an almost empty object + site.sections.get_mut(path).unwrap().pages = prev.pages; + site.sections.get_mut(path).unwrap().ignored_pages = prev.ignored_pages; + site.sections.get_mut(path).unwrap().subsections = prev.subsections; + if site.sections[path].meta == prev.meta { // Front matter didn't change, only content did // so we render only the section page, not its pages diff --git a/docs/content/documentation/getting-started/cli-usage.md b/docs/content/documentation/getting-started/cli-usage.md index 9aa1af44..c6427521 100644 --- a/docs/content/documentation/getting-started/cli-usage.md +++ b/docs/content/documentation/getting-started/cli-usage.md @@ -33,7 +33,7 @@ You can override the config `base_url` by passing a new URL to the `base-url` fl $ gutenberg build --base-url $DEPLOY_URL ``` -This is useful for example when you want to deploy previews of a site to a dynamic URL, such as Netlify +This is useful for example when you want to deploy previews of a site to a dynamic URL, such as Netlify deploy previews. +You can override the default output directory 'public' by passing a other value to the `output-dir` flag. @@ -53,13 +53,13 @@ $ gutenberg --config config.staging.toml build This will build and serve the site using a local server. You can also specify the interface/port combination to use if you want something different than the default (`127.0.0.1:1111`). -You can also specify different addresses for the interface and base_url using `-u`/`--base-url`, for example +You can also specify different addresses for the interface and base_url using `-u`/`--base-url`, for example if you are running Gutenberg in a Docker container. ```bash $ gutenberg serve $ gutenberg serve --port 2000 -$ gutenberg serve --interface 0.0.0.0 +$ gutenberg serve --interface 0.0.0.0 $ gutenberg serve --interface 0.0.0.0 --port 2000 $ gutenberg serve --interface 0.0.0.0 --base-url 127.0.0.1 $ gutenberg serve --interface 0.0.0.0 --port 2000 --output-dir www/public @@ -69,7 +69,7 @@ The serve command will watch all your content and will provide live reload, with hard refresh if possible. Gutenberg does a best-effort to live reload but some changes cannot be handled automatically. If you -fail to see your change, you will need to restart `gutenberg serve`. +fail to see your change or get a weird error, try to restart `gutenberg serve`. You can also point to another config file than `config.toml` like so - the position of the `config` option is important: