mirror of
https://github.com/Hilbis/Hilbish
synced 2025-07-01 16:52:03 +00:00
feat: add color and arrow to indicate current page
This commit is contained in:
parent
046755d551
commit
9e1a484cb4
@ -16,7 +16,11 @@ import jot
|
|||||||
import post
|
import post
|
||||||
import util
|
import util
|
||||||
|
|
||||||
pub fn page(p: post.Post, doc_pages_list) -> element.Element(a) {
|
pub fn page(
|
||||||
|
p: post.Post,
|
||||||
|
this_slug: String,
|
||||||
|
doc_pages_list,
|
||||||
|
) -> element.Element(a) {
|
||||||
html.div([attribute.class("flex-auto flex flex-col overflow-none")], [
|
html.div([attribute.class("flex-auto flex flex-col overflow-none")], [
|
||||||
html.div(
|
html.div(
|
||||||
[
|
[
|
||||||
@ -103,16 +107,37 @@ pub fn page(p: post.Post, doc_pages_list) -> element.Element(a) {
|
|||||||
})
|
})
|
||||||
|> list.first()
|
|> list.first()
|
||||||
[
|
[
|
||||||
html.li([attribute.class("font-bold")], [
|
html.li(
|
||||||
|
[
|
||||||
|
attribute.class(
|
||||||
|
"font-bold"
|
||||||
|
<> case this_slug == { parent_post.1 }.slug {
|
||||||
|
False -> {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
True -> " text-pink-400"
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
[
|
||||||
html.a(
|
html.a(
|
||||||
[
|
[
|
||||||
attribute.href(conf.base_url_join(
|
attribute.href(conf.base_url_join(
|
||||||
{ parent_post.1 }.slug,
|
{ parent_post.1 }.slug,
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
[element.text({ parent_post.1 }.title)],
|
[
|
||||||
|
element.text(
|
||||||
|
case this_slug == { parent_post.1 }.slug {
|
||||||
|
False -> ""
|
||||||
|
True -> " -> "
|
||||||
|
}
|
||||||
|
<> { parent_post.1 }.title,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
]),
|
|
||||||
case list.length(group.1) {
|
case list.length(group.1) {
|
||||||
1 -> element.none()
|
1 -> element.none()
|
||||||
_ ->
|
_ ->
|
||||||
@ -123,12 +148,33 @@ pub fn page(p: post.Post, doc_pages_list) -> element.Element(a) {
|
|||||||
{ p1.1 }.title != { parent_post.1 }.title
|
{ p1.1 }.title != { parent_post.1 }.title
|
||||||
})
|
})
|
||||||
|> list.map(fn(post: #(String, post.Post)) {
|
|> list.map(fn(post: #(String, post.Post)) {
|
||||||
html.li([attribute.class("mb-2")], [
|
html.li(
|
||||||
|
[
|
||||||
|
attribute.class(
|
||||||
|
"mb-2"
|
||||||
|
<> case this_slug == { post.1 }.slug {
|
||||||
|
False -> {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
True -> " text-pink-400"
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
[
|
||||||
html.a(
|
html.a(
|
||||||
[attribute.href(conf.base_url_join(post.0))],
|
[attribute.href(conf.base_url_join(post.0))],
|
||||||
[element.text({ post.1 }.title)],
|
[
|
||||||
|
element.text(
|
||||||
|
case this_slug == { post.1 }.slug {
|
||||||
|
False -> ""
|
||||||
|
True -> " -> "
|
||||||
|
}
|
||||||
|
<> { post.1 }.title,
|
||||||
),
|
),
|
||||||
])
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -35,7 +35,6 @@ pub fn main() {
|
|||||||
_ -> slug
|
_ -> slug
|
||||||
}
|
}
|
||||||
|
|
||||||
io.debug(path)
|
|
||||||
let assert Ok(content) = simplifile.read(path)
|
let assert Ok(content) = simplifile.read(path)
|
||||||
let frontmatter = djot.frontmatter(content)
|
let frontmatter = djot.frontmatter(content)
|
||||||
let metadata = case frontmatter {
|
let metadata = case frontmatter {
|
||||||
@ -82,10 +81,10 @@ pub fn main() {
|
|||||||
|> ssg.add_static_route("/", create_page(index.page()))
|
|> ssg.add_static_route("/", create_page(index.page()))
|
||||||
|> list.fold(posts, _, fn(config, post) {
|
|> list.fold(posts, _, fn(config, post) {
|
||||||
let page = case is_doc_page(post.0) {
|
let page = case is_doc_page(post.0) {
|
||||||
True -> doc.page(post.1, doc_pages)
|
True -> doc.page(post.1, post.0, doc_pages)
|
||||||
False -> doc.page(post.1, doc_pages)
|
False -> doc.page(post.1, post.0, doc_pages)
|
||||||
}
|
}
|
||||||
io.debug(post.0)
|
//io.debug(post.0)
|
||||||
ssg.add_static_route(config, post.0, create_page(page))
|
ssg.add_static_route(config, post.0, create_page(page))
|
||||||
})
|
})
|
||||||
|> ssg.use_index_routes
|
|> ssg.use_index_routes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user