respect :page-index order for navmap
This commit is contained in:
parent
0d4a9c90f6
commit
1ea38c5b84
2 changed files with 24 additions and 21 deletions
|
@ -231,12 +231,13 @@
|
|||
pages-on-level (filter #(= current-level (uri-level (:uri %))) pages-of-parent)
|
||||
pages-on-child-level (filter #(< current-level (uri-level (:uri %))) pages-of-parent)
|
||||
]
|
||||
(map #(let [page-on-level %
|
||||
child-pages (filter-pages-for-uri (:uri page-on-level) pages-on-child-level)]
|
||||
(if (empty? child-pages)
|
||||
page-on-level
|
||||
(merge page-on-level
|
||||
{:navmap-children (build-nav-map-level (:uri page-on-level) child-pages)}))) pages-on-level)
|
||||
(sort-by :page-index
|
||||
(map #(let [page-on-level %
|
||||
child-pages (filter-pages-for-uri (:uri page-on-level) pages-on-child-level)]
|
||||
(if (empty? child-pages)
|
||||
page-on-level
|
||||
(merge page-on-level
|
||||
{:navmap-children (build-nav-map-level (:uri page-on-level) child-pages)}))) pages-on-level))
|
||||
))
|
||||
|
||||
(defn build-nav-map
|
||||
|
|
|
@ -118,31 +118,33 @@ and more content.
|
|||
(reset-resources))
|
||||
|
||||
|
||||
(defn- page [uri]
|
||||
{:navmap? true, :uri uri :content uri})
|
||||
(defn- page [uri page-index]
|
||||
{:navmap? true, :uri uri :content uri :page-index page-index})
|
||||
|
||||
(defn- enhanced-page [uri children]
|
||||
(defn- enhanced-page [uri page-index children]
|
||||
{:navmap? true, :uri uri :content uri
|
||||
:page-index page-index
|
||||
:navmap-children children})
|
||||
|
||||
(deftest test-navmap-pages
|
||||
(testing
|
||||
"No pages or posts nothing to copy"
|
||||
(let [pages [{:navmap? false, :content "1"}
|
||||
(page "/pages/nav1/")
|
||||
(page "/pages/nav1/nav11/")
|
||||
(page "/pages/nav1/nav12/")
|
||||
(page "/pages/nav1/nav13/")
|
||||
(page "/pages/nav1/nav11/nav111/")
|
||||
(page "/pages/nav1/nav11/nav112/")]
|
||||
(page "/pages/nav1/" 0)
|
||||
(page "/pages/nav1/nav11/" 1)
|
||||
(page "/pages/nav1/nav13/" 3)
|
||||
(page "/pages/nav1/nav11/nav112/" 2)
|
||||
(page "/pages/nav1/nav12/" 2)
|
||||
(page "/pages/nav1/nav11/xnav111/" 1)
|
||||
]
|
||||
expected [(enhanced-page
|
||||
"/pages/nav1/"
|
||||
"/pages/nav1/" 0
|
||||
[(enhanced-page
|
||||
"/pages/nav1/nav11/"
|
||||
[(page "/pages/nav1/nav11/nav111/")
|
||||
(page "/pages/nav1/nav11/nav112/")])
|
||||
(page "/pages/nav1/nav12/")
|
||||
(page "/pages/nav1/nav13/")]
|
||||
"/pages/nav1/nav11/" 1
|
||||
[(page "/pages/nav1/nav11/xnav111/" 1)
|
||||
(page "/pages/nav1/nav11/nav112/" 2)])
|
||||
(page "/pages/nav1/nav12/" 2)
|
||||
(page "/pages/nav1/nav13/" 3)]
|
||||
)]
|
||||
]
|
||||
(is (= expected
|
||||
|
|
Loading…
Reference in a new issue