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-level (filter #(= current-level (uri-level (:uri %))) pages-of-parent)
|
||||||
pages-on-child-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 %
|
(sort-by :page-index
|
||||||
child-pages (filter-pages-for-uri (:uri page-on-level) pages-on-child-level)]
|
(map #(let [page-on-level %
|
||||||
(if (empty? child-pages)
|
child-pages (filter-pages-for-uri (:uri page-on-level) pages-on-child-level)]
|
||||||
page-on-level
|
(if (empty? child-pages)
|
||||||
(merge page-on-level
|
page-on-level
|
||||||
{:navmap-children (build-nav-map-level (:uri page-on-level) child-pages)}))) pages-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
|
(defn build-nav-map
|
||||||
|
|
|
@ -118,31 +118,33 @@ and more content.
|
||||||
(reset-resources))
|
(reset-resources))
|
||||||
|
|
||||||
|
|
||||||
(defn- page [uri]
|
(defn- page [uri page-index]
|
||||||
{:navmap? true, :uri uri :content uri})
|
{: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
|
{:navmap? true, :uri uri :content uri
|
||||||
|
:page-index page-index
|
||||||
:navmap-children children})
|
:navmap-children children})
|
||||||
|
|
||||||
(deftest test-navmap-pages
|
(deftest test-navmap-pages
|
||||||
(testing
|
(testing
|
||||||
"No pages or posts nothing to copy"
|
"No pages or posts nothing to copy"
|
||||||
(let [pages [{:navmap? false, :content "1"}
|
(let [pages [{:navmap? false, :content "1"}
|
||||||
(page "/pages/nav1/")
|
(page "/pages/nav1/" 0)
|
||||||
(page "/pages/nav1/nav11/")
|
(page "/pages/nav1/nav11/" 1)
|
||||||
(page "/pages/nav1/nav12/")
|
(page "/pages/nav1/nav13/" 3)
|
||||||
(page "/pages/nav1/nav13/")
|
(page "/pages/nav1/nav11/nav112/" 2)
|
||||||
(page "/pages/nav1/nav11/nav111/")
|
(page "/pages/nav1/nav12/" 2)
|
||||||
(page "/pages/nav1/nav11/nav112/")]
|
(page "/pages/nav1/nav11/xnav111/" 1)
|
||||||
|
]
|
||||||
expected [(enhanced-page
|
expected [(enhanced-page
|
||||||
"/pages/nav1/"
|
"/pages/nav1/" 0
|
||||||
[(enhanced-page
|
[(enhanced-page
|
||||||
"/pages/nav1/nav11/"
|
"/pages/nav1/nav11/" 1
|
||||||
[(page "/pages/nav1/nav11/nav111/")
|
[(page "/pages/nav1/nav11/xnav111/" 1)
|
||||||
(page "/pages/nav1/nav11/nav112/")])
|
(page "/pages/nav1/nav11/nav112/" 2)])
|
||||||
(page "/pages/nav1/nav12/")
|
(page "/pages/nav1/nav12/" 2)
|
||||||
(page "/pages/nav1/nav13/")]
|
(page "/pages/nav1/nav13/" 3)]
|
||||||
)]
|
)]
|
||||||
]
|
]
|
||||||
(is (= expected
|
(is (= expected
|
||||||
|
|
Loading…
Reference in a new issue