@@ -160,7 +160,7 @@ impl Page { | |||
page.slug = { | |||
if let Some(ref slug) = page.meta.slug { | |||
slug.trim().to_string() | |||
slugify(&slug.trim()) | |||
} else if page.file.name == "index" { | |||
if let Some(parent) = page.file.path.parent() { | |||
if let Some(slug) = slug_from_dated_filename { | |||
@@ -437,6 +437,22 @@ Hello world"#; | |||
assert_eq!(page.permalink, config.make_permalink("hello-world")); | |||
} | |||
#[test] | |||
fn can_make_url_from_slug_only_with_no_special_chars() { | |||
let content = r#" | |||
+++ | |||
slug = "hello-&-world" | |||
+++ | |||
Hello world"#; | |||
let config = Config::default(); | |||
let res = Page::parse(Path::new("start.md"), content, &config, &PathBuf::new()); | |||
assert!(res.is_ok()); | |||
let page = res.unwrap(); | |||
assert_eq!(page.path, "hello-world/"); | |||
assert_eq!(page.components, vec!["hello-world"]); | |||
assert_eq!(page.permalink, config.make_permalink("hello-world")); | |||
} | |||
#[test] | |||
fn can_make_url_from_path() { | |||
let content = r#" | |||
@@ -167,12 +167,12 @@ fn can_build_site_without_live_reload() { | |||
assert!(file_contains!( | |||
public, | |||
"sitemap.xml", | |||
"<loc>https%3A//replace-this-with-your-url.com/posts/simple/</loc>" | |||
"<loc>https://replace-this-with-your-url.com/posts/simple/</loc>" | |||
)); | |||
assert!(file_contains!( | |||
public, | |||
"sitemap.xml", | |||
"<loc>https%3A//replace-this-with-your-url.com/posts/</loc>" | |||
"<loc>https://replace-this-with-your-url.com/posts/</loc>" | |||
)); | |||
// Drafts are not in the sitemap | |||
assert!(!file_contains!(public, "sitemap.xml", "draft")); | |||
@@ -280,7 +280,7 @@ fn can_build_site_with_taxonomies() { | |||
assert!(file_contains!( | |||
public, | |||
"categories/a/rss.xml", | |||
"https%3A//replace-this-with-your-url.com/categories/a/rss.xml" | |||
"https://replace-this-with-your-url.com/categories/a/rss.xml" | |||
)); | |||
// Extending from a theme works | |||
assert!(file_contains!(public, "categories/a/index.html", "EXTENDED")); | |||
@@ -291,12 +291,12 @@ fn can_build_site_with_taxonomies() { | |||
assert!(file_contains!( | |||
public, | |||
"sitemap.xml", | |||
"<loc>https%3A//replace-this-with-your-url.com/categories/</loc>" | |||
"<loc>https://replace-this-with-your-url.com/categories/</loc>" | |||
)); | |||
assert!(file_contains!( | |||
public, | |||
"sitemap.xml", | |||
"<loc>https%3A//replace-this-with-your-url.com/categories/a/</loc>" | |||
"<loc>https://replace-this-with-your-url.com/categories/a/</loc>" | |||
)); | |||
} | |||
@@ -425,7 +425,7 @@ fn can_build_site_with_pagination_for_section() { | |||
assert!(file_contains!( | |||
public, | |||
"sitemap.xml", | |||
"<loc>https%3A//replace-this-with-your-url.com/posts/page/4/</loc>" | |||
"<loc>https://replace-this-with-your-url.com/posts/page/4/</loc>" | |||
)); | |||
} | |||
@@ -478,7 +478,7 @@ fn can_build_site_with_pagination_for_index() { | |||
assert!(file_contains!( | |||
public, | |||
"sitemap.xml", | |||
"<loc>https%3A//replace-this-with-your-url.com/page/1/</loc>" | |||
"<loc>https://replace-this-with-your-url.com/page/1/</loc>" | |||
)) | |||
} | |||
@@ -559,7 +559,7 @@ fn can_build_site_with_pagination_for_taxonomy() { | |||
assert!(file_contains!( | |||
public, | |||
"sitemap.xml", | |||
"<loc>https%3A//replace-this-with-your-url.com/tags/a/page/6/</loc>" | |||
"<loc>https://replace-this-with-your-url.com/tags/a/page/6/</loc>" | |||
)) | |||
} | |||
@@ -643,7 +643,7 @@ fn can_apply_page_templates() { | |||
assert_eq!(child.meta.title, Some("Local section override".into())); | |||
} | |||
// https%3A//github.com/getzola/zola/issues/571 | |||
// https://github.com/getzola/zola/issues/571 | |||
#[test] | |||
fn can_build_site_custom_builtins_from_theme() { | |||
let (_, _tmp_dir, public) = build_site("test_site"); | |||
@@ -112,17 +112,17 @@ fn can_build_multilingual_site() { | |||
// sitemap contains all languages | |||
assert!(file_exists!(public, "sitemap.xml")); | |||
assert!(file_contains!(public, "sitemap.xml", "https%3A//example.com/blog/something-else/")); | |||
assert!(file_contains!(public, "sitemap.xml", "https%3A//example.com/fr/blog/something-else/")); | |||
assert!(file_contains!(public, "sitemap.xml", "https%3A//example.com/it/blog/something-else/")); | |||
assert!(file_contains!(public, "sitemap.xml", "https://example.com/blog/something-else/")); | |||
assert!(file_contains!(public, "sitemap.xml", "https://example.com/fr/blog/something-else/")); | |||
assert!(file_contains!(public, "sitemap.xml", "https://example.com/it/blog/something-else/")); | |||
// one rss per language | |||
assert!(file_exists!(public, "rss.xml")); | |||
assert!(file_contains!(public, "rss.xml", "https%3A//example.com/blog/something-else/")); | |||
assert!(!file_contains!(public, "rss.xml", "https%3A//example.com/fr/blog/something-else/")); | |||
assert!(file_contains!(public, "rss.xml", "https://example.com/blog/something-else/")); | |||
assert!(!file_contains!(public, "rss.xml", "https://example.com/fr/blog/something-else/")); | |||
assert!(file_exists!(public, "fr/rss.xml")); | |||
assert!(!file_contains!(public, "fr/rss.xml", "https%3A//example.com/blog/something-else/")); | |||
assert!(file_contains!(public, "fr/rss.xml", "https%3A//example.com/fr/blog/something-else/")); | |||
assert!(!file_contains!(public, "fr/rss.xml", "https://example.com/blog/something-else/")); | |||
assert!(file_contains!(public, "fr/rss.xml", "https://example.com/fr/blog/something-else/")); | |||
// Italian doesn't have RSS enabled | |||
assert!(!file_exists!(public, "it/rss.xml")); | |||
@@ -2,18 +2,18 @@ | |||
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"> | |||
<channel> | |||
<title>{{ config.title }}</title> | |||
<link>{{ config.base_url | urlencode | safe }}</link> | |||
<link>{{ config.base_url | safe }}</link> | |||
<description>{{ config.description }}</description> | |||
<generator>Zola</generator> | |||
<language>{{ config.default_language }}</language> | |||
<atom:link href="{{ feed_url | safe | urlencode | safe }}" rel="self" type="application/rss+xml"/> | |||
<atom:link href="{{ feed_url | safe }}" rel="self" type="application/rss+xml"/> | |||
<lastBuildDate>{{ last_build_date | date(format="%a, %d %b %Y %H:%M:%S %z") }}</lastBuildDate> | |||
{% for page in pages %} | |||
<item> | |||
<title>{{ page.title }}</title> | |||
<pubDate>{{ page.date | date(format="%a, %d %b %Y %H:%M:%S %z") }}</pubDate> | |||
<link>{{ page.permalink | urlencode | safe }}</link> | |||
<guid>{{ page.permalink | urlencode | safe }}</guid> | |||
<link>{{ page.permalink | safe }}</link> | |||
<guid>{{ page.permalink | safe }}</guid> | |||
<description>{% if page.summary %}{{ page.summary }}{% else %}{{ page.content }}{% endif %}</description> | |||
</item> | |||
{% endfor %} | |||
@@ -2,7 +2,7 @@ | |||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | |||
{% for sitemap_entry in entries %} | |||
<url> | |||
<loc>{{ sitemap_entry.permalink | urlencode | safe }}</loc> | |||
<loc>{{ sitemap_entry.permalink | safe }}</loc> | |||
{% if sitemap_entry.date %} | |||
<lastmod>{{ sitemap_entry.date }}</lastmod> | |||
{% endif %} | |||
@@ -1,7 +1,7 @@ | |||
+++ | |||
title = "Fixed slug" | |||
description = "" | |||
slug = "something-else" | |||
slug = "something-&-else" | |||
date = 2017-01-01 | |||
aliases = ["/an-old-url/old-page", "/an-old-url/an-old-alias.html"] | |||
+++ | |||