Fix live reload of section content

This commit is contained in:
Vincent Prouillet 2018-08-05 10:29:53 +02:00
parent f0ba604075
commit 4f418a11b4
3 changed files with 14 additions and 5 deletions

View file

@ -1,6 +1,10 @@
# Changelog # 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 ### Breaking

View file

@ -136,6 +136,11 @@ fn handle_section_editing(site: &mut Site, path: &Path) -> Result<()> {
match site.add_section(section, true)? { match site.add_section(section, true)? {
// Updating a section // Updating a section
Some(prev) => { 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 { if site.sections[path].meta == prev.meta {
// Front matter didn't change, only content did // Front matter didn't change, only content did
// so we render only the section page, not its pages // so we render only the section page, not its pages

View file

@ -69,7 +69,7 @@ The serve command will watch all your content and will provide live reload, with
hard refresh if possible. hard refresh if possible.
Gutenberg does a best-effort to live reload but some changes cannot be handled automatically. If you 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: You can also point to another config file than `config.toml` like so - the position of the `config` option is important: