ppeetteerrs / obsidian-zola

A no-brainer solution to turning your Obsidian PKM into a Zola site.
http://peteryuen.netlify.app/
MIT License
682 stars 138 forks source link

Graph view is broken if a file name contains two spaces in a row #33

Open Ctrl-A-Del opened 2 years ago

Ctrl-A-Del commented 2 years ago

Hi Peter,

I just had an issue where the graph view was broken on all pages due to some new notes I uploaded. It took me some time to figure out, that this happened because I accidentally had two spaces in a row in a file name, like so: " ". Obviously, the fix on my side was just to remove the unnecessary space. However, I still wanted to give you the info.

Uncaught ReferenceError: graph_data is not defined
    at graph.js:22:29

It seems like this resulted in some errors when decoding the URL for the graph_data.

ppeetteerrs commented 2 years ago

Thanks for reporting. That is surprising. Do you have a repo link that I can refer to? Or the exact filename / full error message?

Ctrl-A-Del commented 2 years ago

Here you go. I just did a test commit on my notes to reproduce the issue. This commit has a broken graph: https://gitlab.com/Ctrl-A-Del/pkm-zettelkasten/-/commit/79d57cc13366d4eec82eaab8b4b498849e1e48d7

I have a note called [[🖥️ Tech]] that accidentally had 2 spaces [[🖥️ Tech]] and that killed the graph.

3waffel commented 2 years ago

I've come up with the same issue, and I found that it's probably caused by trying to split two spaces which may produce a null element.

6:52:00 AM: Traceback (most recent call last):
6:52:00 AM:   File "__site/convert.py", line 34, in <module>
6:52:00 AM:     nodes[doc_path.abs_url] = doc_path.page_title
6:52:00 AM:   File "/opt/build/repo/__site/utils.py", line 209, in page_title
6:52:00 AM:     [
6:52:00 AM:   File "/opt/build/repo/__site/utils.py", line 210, in <listcomp>
6:52:00 AM:     item if item[0].isupper() else item.title()
6:52:00 AM: IndexError: string index out of range

In 208-213 of utils.py

        title = " ".join(
            [
                item if item[0].isupper() else item.title()
                for item in self.old_path.stem.split(" ")
            ]
        ).replace('"', r"\"")