---
import Layout from '../layouts/Layout.astro';
import { newsIndex } from '../../utils/rpc';
import { getConfig } from '../../utils/config';
// import { TP2_COLUMN_NEWS, TP2_COLUMN_NEWS_URL, TP2_COLUMN_INDEX, TP2_COLUMN_INDEX_URL } from '../../../../utils/const';
const config = getConfig(Astro)
const {code, data} = await newsIndex(config.id);
console.log(data)
---
<Layout
    isShowHeader = {false}
>
    <main class="v4 main page-news">
        <div class="news-list-component">
            <div class="container">
                <div class="wrap wrap--small">
                    <div class="result-product">
                        <div class="result-product__items news-archive-items">
                            {
                                data.map(news => (
                                    <a href={`/news/${news.id}`} title={news.title} class="result-product__item result-product__item--border">
                                        <div class="result-product__content">
                                            <span class="result-product__label">{news.created_at}</span>
                                            <div class="heading result-product__title">{news.title}</div>
                                            <p class="result-product__info">{news.description}</p>
                                        </div>
                                        <div class="result-product__media ">
                                            <img class="result-product__image img-lazy show success-img" alt={news.title} src={news.cover} onerror="imgErrorUrl(this)" style="" />
                                        </div>
                                    </a>
                                ))
                              }
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>
</Layout>
<style>
    .page-news {
        background-color: #fff !important;
        padding-top: 5rem;
        .result-product__image {
            border-radius: 16px;
        }

        .columns-name {
            font-size: 5rem;
            padding: 3rem;
        }

        @media only screen and (max-width: 767.98px) {
            .columns-name {
                font-size: 2rem;
                padding: 1rem;
            }
        }


        .result-product__media {
            -webkit-box-flex: 0;
            -webkit-flex: 0 0 260px;
            -ms-flex: 0 0 260px;
            flex: 0 0 260px;
            max-width: 260px;
            height: 173.3px;
            position: relative
        }
        .result-product__image {
            max-width: 100%;
            max-height: 100%;
            width: 100%;
            height: 100%;
            border: 0;
            vertical-align: middle;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%,-50%);
            cursor: pointer
        }

        .result-product__item {
            justify-content: space-between;
            align-items: center;
        }

        .result-product__info {
            font-size: 16px;
            font-weight: 500;
            color: #7f7f7f;
            line-height: 1.5
        }

        .result-product__label {
            font-size: 14px;
            font-weight: 500;
            color: #7f7f7f;
            line-height: 1.71;
            display: block;
            margin-bottom: 8px
        }

    .result-product__title {
        font-size: 22px;
        font-weight: 700;
        line-height: 1.45;
        color: #000;
        display: block;
        margin-bottom: 8px;
        max-height: 120px;
        overflow: hidden
    }

    .result-product__item--border {
        border-bottom: 1px solid #ededed
    }

    .result-product__item {
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        padding: 32px 0
    }


    .result-product {
        margin-bottom: 80px
    }

    .result-product:last-of-type {
        margin-bottom: 0
    }

    .result-product__items {
        display: block;
        background-color: #fff
    }

    .result-product__item {
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        padding: 32px 0
    }

    @media only screen and (min-width: 1200px) {
        .no-touch .result-product__item:hover .result-product__title {
            color:#7f7f7f
        }

        .no-touch .result-product__item:hover .result-product__image--thumb::before {
            opacity: .5
        }
    }

    @media screen and (max-width: 768px) {
        .result-product__media {
            -webkit-box-flex: 0;
            -webkit-flex: 0 0 120px;
            -ms-flex: 0 0 120px;
            flex: 0 0 120px;
            height: 90px;
            background-color: unset
        }

        .result-product__info {
            display: none;
        }

        .result-product__title {
            font-size: 15px;
        }

        .result-product__content  {
            display: flex;
            flex-direction: column-reverse;
        }
    }

    .result-product__item--border {
        border-bottom: 1px solid #ededed
    }

    .result-product__item-title {
        font-size: 22px;
        font-weight: 700;
        line-height: 1.45;
        color: #000;
        display: block;
        padding-bottom: 24px;
        padding-top: 80px
    }

    .result-product__item-title--big {
        font-size: 32px;
        line-height: 1.25;
        letter-spacing: -0.5px
    }

    .result-product__label {
        font-size: 14px;
        font-weight: 500;
        color: #7f7f7f;
        line-height: 1.71;
        display: block;
        margin-bottom: 8px
    }

    .result-product__content-text {
        position: relative;
        -webkit-transform: translateY(-50%);
        transform: translateY(-50%);
        top: 50%;
        max-width: 730px;
        padding-right: 20px
    }
}

</style>
