To Steal An Aesthetic. To Find Beauty in an API.
Beautiful design is addicting to look at. This fact is especially true when the design is brilliantly simple. I first saw https://2pml.com/ on a chilly Saturday morning and the greed to have the same immediately began to bubble and fester.
If only I was a software developer who wanted to work on his frontend skills. Fortunately, I am a that developer. Moreover, I am that exact developer obsessed with improving his frontend skills. And thus, from these simple truths, The Rat was born.
The Morning
In the morning, I built the page.
What elegant edges. What a powerful lightning-yellow button. What a concerning political war being waged by the cats. I do admit, I may have initially included photo of a rat.
The code behind my clone isn't really important. What is important is that I showed myself I could successfully mimic the look of another webpage in a focused morning. What could I do if I added a focused afternoon?
The Afternoon
Someone once told me that Ghost has an API. Surely that API can give me the contents of my articles? What was that? It can!?
I will simply copy-paste the example...
export const GET = (async ({ url }) => {
const api = new GhostContentAPI({
url: 'https://XXXXXXXX.ghost.io',
key: ghostContentApiKey,
version: "v5.0"
});
// fetch 5 posts, including related tags and authors
let limit = url.searchParams.get('limit') || 6
let posts = await api.posts.browse({ limit: limit, include: 'tags,authors' })
posts = posts.map(post => { return { title: post.title, excerpt: post.excerpt, author: post.primary_author.name, authorId: post.primary_author.id, id: post.id, updatedAt: post.updated_at, html: post.html } })
return json(posts);
}) satisfies RequestHandler;
And it works:
Writing code is so easy.