emacs-love / weblorg

Static Site Generator for Emacs
https://emacs.love/weblorg
GNU General Public License v3.0
278 stars 20 forks source link

Route names that include a hyphen cause url_for link exports to fail #22

Closed sethm closed 3 years ago

sethm commented 3 years ago

I set up a very simple new site to play with with the following structure:

.
├── blog
│   ├── first_post.org
│   └── second_post.org
├── pages
│   └── index.org
├── publish.el
└── templates
    ├── blog.html
    ├── layout.html
    ├── page.html
    └── post.html

My publish.el contains the following routes:

(weblorg-route
 :name "pages"
 :input-pattern "pages/*.org"
 :template "page.html"
 :output "output/{{ slug }}.html"
 :url "/{{ slug }}.html")

(weblorg-route
 :name "blog"
 :input-pattern "blog/*.org"
 :template "post.html"
 :output "output/blog/{{ slug }}.html"
 :url "/blog/{{ slug }}.html")

(weblorg-route
 :name "blog-index"
 :input-pattern "blog/*.org"
 :input-aggregate #'weblorg-input-aggregate-all-desc
 :template "blog.html"
 :output "output/blog/index.html"
 :url "/blog/")

In my main index.org, I have the following link:

[[url_for:blog-index,slug=index][Check out my blog]]

Publishing fails with the error:

Template Error: Variable `slug' not declared

Doing a little digging around, it looks like the problem is actually the hyphen in the name of the route blog-index! If, instead of blog-index, I rename the route to blog_index, and change the link to [[url_for:blog_index,slug=index]], publishing works perfectly.

clarete commented 3 years ago

Hi @sethm, thank you for taking the time to write such a thorough bug report. I found the culprit of the issue and fixed it here: 55590fe44a6dc970354559a1f0a3cb045c52c254. I'm going to close the ticket but it might take a tiny bit for melpa to re-build the package (in case that's the source you use).

Please reopen this ticket or file a new one if that doesn't work for you! :D

sethm commented 3 years ago

Works perfectly, thank you!