'); $.each(_items,(i, item) => { const $templateBody = $($template.html()); const titleText = item.title; const linkPdf = item.link_pdf; const linkUrl = item.link_url; const linkUrlBlank = item.linkUrlBlank; const permaLink = item.permalink; const subTitleText = item.subtitle; const dateString = item.date; const isInvalidDate = (date) => Number.isNaN(new Date(date).getTime()); const date = !isInvalidDate(dateString) ? new Date(dateString) : new Date(dateString.substring(0, 4), dateString.substring(4, 6) - 1, dateString.substring(6, 8)); const categories = Array.isArray(item.category) ? item.category : item.category.split(","); const $title = $(""); const $blankIcon = $(''); //const formattedDate = `${date.getFullYear()}年${date.getMonth()+1}月${(date.getDate())}日`; const formattedDate = `${date.getFullYear()}年${date.getMonth()+1}月${(' ' + date.getDate()).slice(-2)}日`; const $category = $('.entry-cat', $templateBody); $('.entry-date', $templateBody).text(formattedDate); $title.append(titleText); if(linkPdf) { $title.attr({'href':linkPdf,'target':"_blank"}).find("a").append($blankIcon); } else if(linkUrl) { linkUrlBlank ? $title.attr({'href':linkUrl,'target':"_blank"}).find("a").append($blankIcon) : $title.attr({'href':linkUrl}); } if(permaLink) { $title.attr({'href':permaLink}); } $('.entry-title', $templateBody).append($title); $('.sub-ttl', $templateBody).text(subTitleText); if(categories) { $.each(categories, function(j, category) { const $categoryAdd = $category.clone(); $categoryAdd.text(category); $category.parent().append($categoryAdd); if(!_subCategoryShow) return false; }); $category.remove() } $templateWrapper.append($templateBody); }); return $($templateWrapper.html()); } });