Browse Source

Fix internal links to content dir not working

Closes #275
index-subcmd
Vincent Prouillet 6 years ago
parent
commit
d9dbf4d567
4 changed files with 16 additions and 1 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +5
    -1
      components/content/src/file_info.rs
  3. +8
    -0
      components/utils/src/site.rs
  4. +2
    -0
      test_site/content/posts/draft.md

+ 1
- 0
CHANGELOG.md View File

@@ -14,6 +14,7 @@ to the public directory
want to link directly to it
- Fix many shortcode parsing issues
- Correctly copy themes shortcodes so they are useable in content
- Fix internal links not working for markdown files directly in `content` directory

## 0.3.2 (2018-03-05)



+ 5
- 1
components/content/src/file_info.rs View File

@@ -48,7 +48,11 @@ impl FileInfo {
let mut parent = file_path.parent().unwrap().to_path_buf();
let name = path.file_stem().unwrap().to_string_lossy().to_string();
let mut components = find_content_components(&file_path);
let relative = format!("{}/{}.md", components.join("/"), name);
let relative = if !components.is_empty() {
format!("{}/{}.md", components.join("/"), name)
} else {
format!("{}.md", name)
};

// If we have a folder with an asset, don't consider it as a component
if !components.is_empty() && name == "index" {


+ 8
- 0
components/utils/src/site.rs View File

@@ -46,6 +46,14 @@ mod tests {
assert_eq!(res, "https://vincent.is/about");
}

#[test]
fn can_resolve_valid_root_internal_link() {
let mut permalinks = HashMap::new();
permalinks.insert("about.md".to_string(), "https://vincent.is/about".to_string());
let res = resolve_internal_link("./about.md", &permalinks).unwrap();
assert_eq!(res, "https://vincent.is/about");
}

#[test]
fn can_resolve_internal_links_with_anchors() {
let mut permalinks = HashMap::new();


+ 2
- 0
test_site/content/posts/draft.md View File

@@ -6,3 +6,5 @@ date = 2016-03-01


{{ theme_shortcode() }}

Link to [root](./hello.md).

Loading…
Cancel
Save