Public
Edited
Aug 21, 2024
1 fork
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
html`<h3>Current Hacker News homepage</h3>
<ul>
${content
.map(
(item) => `
<li>
<h3>
<a href="https://news.ycombinator.com/item?id=${
item.objectID
}" target="_blank">
${item.title}
</a>
</h3>
<p>ID: ${item.objectID} | Points: ${item.points}</p>
<p><a href="${item.url}">${item.url}</a></p>
<p>Created: ${new Date(
item.created_at
).toLocaleString()} | Updated: ${new Date(
item.updated_at
).toLocaleString()}</p>
<p>
<a href="https://hn.algolia.com/?dateRange=all&page=0&prefix=false&query=story%3A${
item.objectID
}&sort=byDate&type=comment" target="_blank">
Search ${item.num_comments} comments by most recent first
</a> / <a href="https://news.ycombinator.com/latest?id=${
item.objectID
}">latest</a>
</p>
</li>
`
)
.join("")}
</ul>
`
Insert cell
output = {
if (url) {
const match = url.match(/\d+/);
if (match) {
return `https://hn.algolia.com/?dateRange=all&page=0&prefix=false&query=story%3A${match[0]}&sort=byDate&type=comment`;
}
}
}
Insert cell
content = homepage.hits.map(
({ objectID, points, created_at, updated_at, title, num_comments, url }) => ({
objectID,
points,
created_at,
updated_at,
title,
num_comments,
url
})
)
Insert cell
Inputs.table(content)
Insert cell
Inputs.table(homepage.hits)
Insert cell
homepage = (
await fetch(
"https://hn.algolia.com/api/v1/search?tags=front_page&hitsPerPage=30"
)
).json()
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more