1$(function () { 2 3 <!-- microcms-js-sdkãæ£ããèªã¿è¾¼ã --> 4 // ãããã°ç¨ã®ãã° 5 6 // microCMSã¯ã©ã¤ã¢ã³ãã使 7 const client = microcms.createClient({ 8 serviceDomain: 'hodai-globis', 9 apiKey: '64c82bfcd18c4ee7b78d5b76d20263dba708', 10 }); 11 12 // ãããã°ç¨ã®ãã° 13 14 // ãã¥ã¼ã¹ãåå¾ãã¦è¡¨ç¤º 15 function fetchNews() { 16 17 client.get({ 18 endpoint: 'article', 19 queries: { 20 limit: 500, 21 fields: ['id', 'name', 'publishedAt', 'tag', 'category', 'image', 'main_image'], 22 filters: 'publishedAt[greater_than]2024-01-01', 23 orders: '-publishedAt' 24 }, 25 }) 26 .then((res) => { 27 if (!res || !res.contents || !Array.isArray(res.contents)) { 28 console.error('äºæããªãã¬ã¹ãã³ã¹å½¢å¼:', res); 29 return; 30 } 31 32 33 // G-STARTUPã¿ã°ãæã¤è¨äºããã£ã«ã¿ãªã³ã° 34 const filteredContents = res.contents.filter(news => { 35 if (!news.tag || !Array.isArray(news.tag)) return false; 36 37 // åè¨äºã®ã¿ã°ããã°åºå 38 39 return news.tag.some(tag => { 40 // ã¿ã°ã®æ§é ããã°åºå 41 42 if (typeof tag === 'string') { 43 return tag === 'G-STARTUP'; 44 } 45 if (typeof tag === 'object' && tag !== null) { 46 return tag.name === 'G-STARTUP'; 47 } 48 return false; 49 }); 50 }); 51 52 53 // æåã®3ä»¶ã«å¶é 54 const limitedContents = filteredContents.slice(0, 3); 55 56 if (limitedContents.length === 0) { 57 console.log('該å½ããã³ã³ãã³ããåå¨ãã¾ãã'); 58 const newsList = document.getElementById('news-list'); 59 newsList.innerHTML = '<li>2024年以éã®G-STARTUPè¨äºã¯è¦ã¤ããã¾ãã</li>'; 60 return; 61 } 62 63 const newsList = document.getElementById('news-list'); 64 newsList.innerHTML = ''; 65 limitedContents.forEach(news => { 66 const listItem = document.createElement('li'); 67 // listItem.style.marginBottom = '20px'; 68 69 70 // è¨äºã®ã³ã³ããã使 71 const contentDiv = document.createElement('div'); 72 contentDiv.style.display = 'inline-block'; 73 contentDiv.style.verticalAlign = 'middle'; 74 75 // ã¿ã¤ãã«ããªã³ã¯ã«ãã 76 const titleLink = document.createElement('a'); 77 titleLink.href = `https://globis.jp/article/${news.id}`; // URLãä¿®æ£ 78 titleLink.target = '_blank'; 79 titleLink.textContent = news.name || 'ç¡é¡'; 80 titleLink.style.textDecoration = 'none'; 81 // titleLink.style.color = '#333'; 82 // titleLink.style.fontWeight = 'bold'; 83 contentDiv.appendChild(titleLink); 84 85 // æ¥ä»ã追å 86 const date = new Date(news.publishedAt); 87 const formattedDate = `${date.getFullYear()}.${date.getMonth() + 1}.${date.getDate()}`; 88 const dateSpan = document.createElement('span'); 89 dateSpan.textContent = ` ${formattedDate}`; 90 dateSpan.style.color = '#666'; 91 contentDiv.appendChild(dateSpan); 92 93 // ã¿ã°æ å ±ã追å 94 // if (news.tag && Array.isArray(news.tag)) { 95 // const tagNames = news.tag.map(tag => 96 // typeof tag === 'string' ? tag : (tag.name || 'Unknown tag') 97 // ); 98 // const tagSpan = document.createElement('span'); 99 // tagSpan.textContent = ` [Tags: ${tagNames.join(', ')}]`; 100 // tagSpan.style.color = '#888'; 101 // contentDiv.appendChild(tagSpan); 102 // } 103 104 listItem.appendChild(contentDiv); 105 newsList.appendChild(listItem); 106 }); 107 108 // ãªã¹ãã®ã¹ã¿ã¤ã«ãèª¿æ´ 109 newsList.style.listStyle = 'none'; 110 newsList.style.padding = '0'; 111 }) 112 .catch((error) => { 113 console.error('ã¨ã©ã¼ã®è©³ç´°:', error); 114 }); 115 } 116 117 // 峿å®è¡ 118 fetchNews(); 119 120});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.