<!DOCTYPE html>
<html lang="vi">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hiển Thị Tác Phẩm</title>
<style>.khung{border:1px solid var(--contentL);border-radius:30px;background-color:var(--contentB);margin-bottom:20px;padding:10px}.hang-dau{font-weight:700;margin-bottom:10px;display:flex;justify-content:space-between}.hang-dau span{flex:1;text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 5px;color:var(--darkTa)}.hang-dau span:first-child{text-align:left}.hang-dau span:last-child{text-align:right}.hang-dau span:nth-child(2) a{background-color:var(--linkB);color:white!important;padding:2px 8px}.hang-dau span:nth-child(2){background-color:var(--linkB);color:white!important}.hang-thu-hai{display:flex}.hang-thu-hai .bia{width:30%;position:relative;overflow:hidden;border-radius:10px;margin:10px}.hang-thu-hai .bia img{width:100%;aspect-ratio:2 / 3;object-fit:cover}.hang-thu-hai .noi-dung{width:70%;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;text-align:justify;margin:10px;margin-bottom:20px}.hang-thu-ba{margin-top:10px;display:flex;flex-wrap:nowrap;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.hang-thu-ba .label{background-color:var(--contentBs);padding:2px 8px;margin-right:5px;white-space:nowrap;border-radius:6px}.ribbon{position:absolute;top:-3px;right:0;background:linear-gradient(135deg,#FFA726,#FB8C00);color:#fff;font-size:8px;font-weight:700;text-transform:uppercase;padding:3px 18px 3px 5px;border-bottom-left-radius:8px;border-bottom-right-radius:8px;box-shadow:0 4px 6px rgb(0 0 0 / .3);z-index:1;line-height:1.5}.ribbon span{font-size:7px;margin-right:14px;display:block;font-weight:700;transform:translateY(20px)}.circle{position:absolute;top:-3px;right:-5px;width:20px;height:20px;background-color:#fff;border-radius:50%;display:flex;align-items:center;justify-content:center;z-index:2}.circle svg{width:12px;height:12px;margin-top:4px;margin-left:-4px}</style>
</head>
<body>
    <div id="container"></div>

<script>async function fetchData(){try{const response=await fetch('https://script.google.com/macros/s/AKfycbwoq5ahEyasnXZARvOprBUogCYeJI6zz2B6dVc2syd-q3NAHu8h3NVradvMUqB0cvVV8Q/exec?os=new');const data=await response.json();displayData(data)}catch(error){console.error('Lỗi khi lấy dữ liệu:',error)}}
function formatVietnamDate(dateString){const date=new Date(dateString);const day=date.getDate().toString().padStart(2,'0');const month=(date.getMonth()+1).toString().padStart(2,'0');const year=date.getFullYear();return `${day}/${month}/${year}`}
function displayData(data){const container=document.getElementById('container');data.forEach(item=>{const khung=document.createElement('div');khung.className='khung';const hangDau=document.createElement('div');hangDau.className='hang-dau';const formattedDate=formatVietnamDate(item['Thời gian']);hangDau.innerHTML=`
                	<span>${item['Tác giả']}</span>
                    <span><a href="${item['Link tác phẩm']}" class="link-tac-pham">${item['Tác phẩm']}</a></span>
                    
                    <span>${formattedDate}</span>
                `;const hangThuHai=document.createElement('div');hangThuHai.className='hang-thu-hai';const bia=document.createElement('div');bia.className='bia';const img=document.createElement('img');img.src=item['Url bìa'];img.alt='Bìa sách';const ribbon=document.createElement('span');ribbon.className='ribbon';ribbon.textContent=`${item['Lượt xem']}`;const circle=document.createElement('span');circle.className='circle';circle.innerHTML=`
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
  <g id="SVGRepo_bgCarrier" stroke-width="0"></g>
  <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
  <g id="SVGRepo_iconCarrier">
    <!-- Đường viền với gradient vàng -->
    <path d="M16.243 5.00067C13.5746 3.66644 10.4336 3.66644 7.76519 5.00067C6.15284 5.80685 4.80381 7.05609 3.87635 8.60186L2.65914 10.6305C2.15366 11.473 2.15366 12.5255 2.65914 13.368L3.87635 15.3966C4.80381 16.9424 6.15284 18.1916 7.76519 18.9978C10.4336 20.3321 13.5746 20.3321 16.243 18.9978C17.8554 18.1916 19.2044 16.9424 20.1319 15.3966L21.3491 13.368C21.8546 12.5255 21.8545 11.473 21.3491 10.6305L20.1319 8.60186C19.2044 7.05609 17.8554 5.80685 16.243 5.00067Z" fill="url(#grad1)"></path>
    
    <!-- Vòng tròn bên trong màu vàng -->
    <path fill-rule="evenodd" clip-rule="evenodd" d="M12.0037 9.99927C10.8994 9.99927 10.0042 10.8941 10.0042 11.9997C10.0042 13.1043 10.8992 13.9993 12.0037 13.9993C13.1086 13.9993 14.0042 13.1039 14.0042 11.9997C14.0042 10.8945 13.1084 9.99927 12.0037 9.99927ZM8.00415 11.9997C8.00415 9.78991 9.79438 7.99927 12.0037 7.99927C14.2126 7.99927 16.0042 9.78949 16.0042 11.9997C16.0042 14.2092 14.2124 15.9993 12.0037 15.9993C9.79458 15.9993 8.00415 14.2088 8.00415 11.9997Z" fill="#fff"></path>
  </g>

  <!-- Định nghĩa gradient vàng -->
  <defs>
    <linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="100%">
      <stop offset="0%" style="stop-color:#FFA726;stop-opacity:1"></stop>
      <stop offset="100%" style="stop-color:#FB8C00;stop-opacity:1"></stop>
    </linearGradient>
  </defs>
</svg>

                `;bia.appendChild(img);bia.appendChild(ribbon);bia.appendChild(circle);const noiDung=document.createElement('div');noiDung.className='noi-dung';noiDung.textContent=item['Nội dung'];hangThuHai.appendChild(bia);hangThuHai.appendChild(noiDung);const hangThuBa=document.createElement('div');hangThuBa.className='hang-thu-ba';const theLoai=item['Thể loại'].split(',').map(tl=>tl.trim());theLoai.forEach(tl=>{const label=document.createElement('span');label.className='label';label.textContent=tl;hangThuBa.appendChild(label)});khung.appendChild(hangDau);khung.appendChild(hangThuHai);khung.appendChild(hangThuBa);container.appendChild(khung)})}
fetchData();</script>
</body>
</html>
