Browse Source

Fix reload with taxonomies

index-subcmd
Vincent Prouillet 6 years ago
parent
commit
aee41f279c
4 changed files with 18 additions and 4 deletions
  1. +2
    -0
      CHANGELOG.md
  2. +3
    -0
      components/rebuild/src/lib.rs
  3. +10
    -4
      components/site/tests/site.rs
  4. +3
    -0
      test_site/content/rebuild/first.md

+ 2
- 0
CHANGELOG.md View File

@@ -10,6 +10,8 @@
Tera function Tera function
- Table of content now strips HTML from the titles to avoid various issues - Table of content now strips HTML from the titles to avoid various issues
- `gutenberg-anchor` CSS class has been renamed `zola-anchor` - `gutenberg-anchor` CSS class has been renamed `zola-anchor`
- `data` is now a reserved variable name in templates, it is unused right now but
might change soon.


### Others ### Others
- Many many times faster (x5-x40) for most sites - Many many times faster (x5-x40) for most sites


+ 3
- 0
components/rebuild/src/lib.rs View File

@@ -118,6 +118,7 @@ fn delete_element(site: &mut Site, path: &Path, is_section: bool) -> Result<()>
} }


site.populate_sections(); site.populate_sections();
site.populate_taxonomies()?;
// Ensure we have our fn updated so it doesn't contain the permalink(s)/section/page deleted // Ensure we have our fn updated so it doesn't contain the permalink(s)/section/page deleted
site.register_early_global_fns(); site.register_early_global_fns();
site.register_tera_global_fns(); site.register_tera_global_fns();
@@ -190,6 +191,7 @@ fn handle_page_editing(site: &mut Site, path: &Path) -> Result<()> {
// Updating a page // Updating a page
Some(prev) => { Some(prev) => {
site.populate_sections(); site.populate_sections();
site.populate_taxonomies()?;


// Front matter didn't change, only content did // Front matter didn't change, only content did
if site.library.get_page(&pathbuf).unwrap().meta == prev.meta { if site.library.get_page(&pathbuf).unwrap().meta == prev.meta {
@@ -362,6 +364,7 @@ pub fn after_template_change(site: &mut Site, path: &Path) -> Result<()> {
site.render_markdown()?; site.render_markdown()?;
} }
site.populate_sections(); site.populate_sections();
site.populate_taxonomies()?;
site.render_sections()?; site.render_sections()?;
site.render_orphan_pages()?; site.render_orphan_pages()?;
site.render_taxonomies() site.render_taxonomies()


+ 10
- 4
components/site/tests/site.rs View File

@@ -169,8 +169,11 @@ fn can_build_site_without_live_reload() {
assert!(file_exists!(public, "posts/tutorials/devops/index.html")); assert!(file_exists!(public, "posts/tutorials/devops/index.html"));
assert!(file_contains!(public, "posts/tutorials/devops/index.html", "docker")); assert!(file_contains!(public, "posts/tutorials/devops/index.html", "docker"));


// No tags or categories
assert_eq!(file_exists!(public, "categories/index.html"), false);
// We do have categories
assert_eq!(file_exists!(public, "categories/index.html"), true);
assert_eq!(file_exists!(public, "categories/a-category/index.html"), true);
assert_eq!(file_exists!(public, "categories/a-category/rss.xml"), true);
// But no tags
assert_eq!(file_exists!(public, "tags/index.html"), false); assert_eq!(file_exists!(public, "tags/index.html"), false);


// Theme files are there // Theme files are there
@@ -245,8 +248,11 @@ fn can_build_site_with_live_reload() {
assert!(file_exists!(public, "posts/tutorials/programming/index.html")); assert!(file_exists!(public, "posts/tutorials/programming/index.html"));
// TODO: add assertion for syntax highlighting // TODO: add assertion for syntax highlighting


// No tags or categories
assert_eq!(file_exists!(public, "categories/index.html"), false);
// We do have categories
assert_eq!(file_exists!(public, "categories/index.html"), true);
assert_eq!(file_exists!(public, "categories/a-category/index.html"), true);
assert_eq!(file_exists!(public, "categories/a-category/rss.xml"), true);
// But no tags
assert_eq!(file_exists!(public, "tags/index.html"), false); assert_eq!(file_exists!(public, "tags/index.html"), false);


// no live reload code // no live reload code


+ 3
- 0
test_site/content/rebuild/first.md View File

@@ -2,6 +2,9 @@
title = "first" title = "first"
weight = 10 weight = 10
date = 2017-01-01 date = 2017-01-01

[taxonomies]
categories = ["a-category"]
+++ +++


# A title # A title

Loading…
Cancel
Save