1const url = window.location.origin + '/' 2 3// this is OK to expose as its content only. do not fret traveller. 4const api_keys = { 5 local: '6d8eda860095022d4b8dbd773f', 6 staging: 'cba45d9c96446cbc6a31b2e4ac', 7 production: '473a091d71e06e5b27c35bcf5d' 8} 9const is_local = url.includes('localhost') || url.includes('127.0') 10const is_staging = url.includes('staging') 11const api_key = is_local ? api_keys.local : is_staging ? api_keys.staging : api_keys.production 12 13const categorySlug = typeof currentCategorySlug !== 'undefined' ? currentCategorySlug : ''; 14const extra_filter_tag = categorySlug ? `%2Btag%3A${categorySlug}` : ''; 15const container = document.querySelector('.latest-from-category .gh-header-middle') 16let page = 2; 17 18const retryOperation = (operation, params, delay, retries) => new Promise((resolve, reject) => { 19 return operation(...params) 20 .then(resolve) 21 .catch((reason) => { 22 if (retries > 0) { 23 return wait(delay) 24 .then(retryOperation.bind(null, operation, params, delay, retries - 1)) 25 .then(resolve) 26 .catch(reject); 27 } 28 return reject(reason); 29 }); 30}); 31 32const wait = ms => new Promise(r => setTimeout(r, ms)); 33 34async function loadMoreArticles(per_page = 20) { 35 const response = await fetch(`${url}ghost/api/content/posts?key=${api_key}&include=tags&page=${page}&limit=${per_page}&filter=tag%3A-hash-race-results%2Btag%3A-hash-hub%2Btag%3A-hash-unlist${extra_filter_tag}`) 36 const data = await response.json() 37 38 if (data.posts.length === 0 || page > data.meta.pagination.pages) { 39 document.getElementById('load-more-articles-button').style.display = 'none' 40 return 41 } 42 43 data.posts.forEach(post => { 44 const post_node = document.createElement('article') 45 post_node.classList.add('gh-card', 'post-card-inline', 'post') 46 const primaryTag = post.tags && post.tags.find(t => !t.slug.startsWith('hash-')) 47 post_node.innerHTML = ` 48 <a class='gh-card-link' href='${post.url}'> 49 ${post.feature_image ? `<figure class='gh-card-image'> 50 <img src='${post.feature_image}' alt='${post.title}'/> 51 </figure>` : ''} 52 <div class='gh-card-wrapper'> 53 ${primaryTag ? `<p class='gh-card-tag'>${primaryTag.name}</p>` : ''} 54 <h3 class='gh-card-title is-title'>${post.title}</h3> 55 <p class='gh-card-excerpt is-body'>${post.excerpt}</p> 56 </div> 57 </a> 58 ` 59 container.appendChild(post_node) 60 }) 61 page++ 62 63 if(page > data.meta.pagination.pages) { 64 document.getElementById('load-more-articles-button').style.display = 'none' 65 } 66}
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.