/*
    This file is part of jellything (https://codeberg.org/metamuffin/jellything)
    which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
    Copyright (C) 2026 metamuffin <metamuffin.org>
*/

use crate::{
    RenderInfo,
    components::node_card::{NodeCard, NodeCardHightlight},
    page,
};
use jellycommon::Nku;
use jellyui_locale::tr;

pub enum HomeRow<'a> {
    Inline(Vec<Nku<'a>>),
    Highlight(Nku<'a>),
}

page!(Home<'_>, |x| tr(x.ri.lang, "home"));

markup::define! {
    Home<'a>(ri: &'a RenderInfo<'a>, rows: &'a [(&'a str, HomeRow<'a>)]) {
        @for (title, row) in *rows {
            h2 { @tr(ri.lang, title) }
            @match row {
                HomeRow::Inline(nkus) => {
                    ul.nl.inline { @for nku in nkus {
                        li { @NodeCard { ri, nku } }
                    }}
                }
                HomeRow::Highlight(nku) => {
                    @NodeCardHightlight { ri, nku }
                }
            }
        }
    }
}
