Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Yuen authored and Peter Yuen committed Apr 17, 2022
2 parents 99390b2 + 64c5080 commit a886481
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ How to sort your pages inside a folder ("title" or "date"). Default: "title". F
Google Analytics Measurement ID. Default: "".

### `SLUGIFY`
Whether to slugify URLs. Set to "" to disable. Default: "y".
Whether to slugify URLs. Set to "" to disable (use at your own risk, filenames with special symbols might not show up correctly in the graph view). Default: "y".

### `HOME_GRAPH`
Shows knowledge graph on home page. Put "" to disable. Default: "y".
Expand Down
7 changes: 4 additions & 3 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pathlib import Path
from pprint import PrettyPrinter
from typing import Dict, List, Optional, Tuple, Union
from urllib.parse import unquote
from urllib.parse import quote, unquote

from slugify import slugify

Expand Down Expand Up @@ -111,7 +111,8 @@ def abs_url(self, doc_path: "DocPath") -> str:
.resolve()
.relative_to(docs_dir)
)
new_rel_path = slugify_path(new_rel_path)
new_rel_path = quote(str(slugify_path(new_rel_path)))

return f"/docs/{new_rel_path}"
except Exception:
print(f"Invalid link found: {doc_path.old_rel_path}")
Expand Down Expand Up @@ -240,7 +241,7 @@ def copy(self):
def abs_url(self) -> str:
"""Returns an absolute URL to the page."""
assert self.is_md
return f"/docs/{str(self.new_rel_path)[:-3]}"
return quote(f"/docs/{str(self.new_rel_path)[:-3]}")

def edge(self, other: str) -> Tuple[str, str]:
"""Gets an edge from page's URL to another URL."""
Expand Down
6 changes: 5 additions & 1 deletion zola/static/js/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ if (curr_url.endsWith("/")) {
var container = document.getElementById("graph");

// Parse nodes and edges
var curr_node = graph_data.nodes.filter((node) => node.url == curr_url);
try {
var curr_node = graph_data.nodes.filter((node) => decodeURI(node.url) == curr_url);
} catch (error) {
var curr_node = null;
}
var nodes = null;
var edges = new vis.DataSet(graph_data.edges);

Expand Down

0 comments on commit a886481

Please sign in to comment.