I have converted some Noir sites to Compojure.
I have a function that creates a page layout:
(defn layout [title & content] (html5 [:head [:title "My Site | " title] (include-css "css/main.css") [:body [:header [:h1 (link-to "/" "My Site")]] content]))
And this is the function and routes:
(defn home-page [] (layout "Home" [:div [:p "Home Page"]]))) (defn article-list [] (layout "Article List" [:div [:p "Article List"]]))) (defroutes app-routes (GET "/" [] (home-page)) (GET "/article-list" [] (article-list))
When I open localhost: 3000 / article-list, all CSS rules work fine.
However, when I try to expand the URL and change the program, follow these steps:
(defn article-list [] (layout "Article List" [:div [:p "Article List"]]))) (defn article-one [] (layout "Article One" [:div [:p "Article One"]]))) (defroutes app-routes (GET "/" [] (home-page)) (GET "/article-list" [] (article-list) (GET "/article-list/article-one" [] (article-one))
And go to localhost: 3000 / article-list / article-one, I get all the HTML, but the CSS rules no longer work. When I check the page, css paths are included in the <head>, but there are no styles on the page.
I was looking for a solution to this problem, but it seems not written about it. I also tried pulling out the routes so that I had:
(defroutes article-routes (GET "/article-list/article-one" [] (article-one)) (defroutes app-routes (GET "/" [] (home-page)) (GET "/article-list" [] (article-list) (context "article-list" [] article-routes)
but i have the same problem. How can I make CSS rules work on pages with advanced paths?