# データ取得関数 export async function getStaticProps(_ctx) { // IR資料 const response = await fetch(‘https://ssl4.eir-parts.net/V4Public/EIR/8746/ja/announcement/announcement_1.js’), text = await response.text(); // 1行目と最終行を除外してJSON化 const json = JSON.parse(text.split(“\n”).slice(1, -1).join(” “)); // お知らせ const topics = await News.query().where(‘kb_hyouji’, 1).where(‘cd_icon’, 5).where(‘hh_date’, ‘>’,’2022/08/01′).orderBy(‘ix_article’, ‘desc’).limit(3); return { props: { // 先頭3要素 news : json.item.slice(0, 3).map(elem => { const date = new DateTime(elem.date); return { date : `${date.getFullYear()}.${date.get0Month()}.${date.get0Date()}`, href : elem.link || ‘#’, type : NewsTypes[elem.news_type], title: elem.title, }; }), topics: topics.map(elem => { return { id : elem.ix_article, date : elem.hh_date.toYmd(), title : elem.xx_title, href : elem.href, target: elem.target, type : TopicsTypes[elem.cd_icon], } }), }, // 再更新 revalidate: 60 }; } # データ表示部分 render() { const {news} = this.props; return (
最新IR資料
{news.map(elem =>
{elem.date.replace(/\./g,’-‘)}
{elem.title}
)}
);