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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more