///////////////////////////////////////////// //* IMPORTS ///////////////////////////////////////////// import React from "react"; import { Metadata } from "next"; const datasquirel = require("datasquirel"); import { headers, cookies } from "next/headers"; ///////////////////////////////////////////// //* Metadata ///////////////////////////////////////////// export const metadata: Metadata = { title: "Blog posts | Tben.me", description: "Tech talks and tutorials by Tben", }; export const revalidate = 3600; ///////////////////////////////////////////// //* Main Function ///////////////////////////////////////////// /** * Blog page index * ============================================================================== */ export default async function BlogIndex() { //* Data fetching ///////////////////////////////////////////// const postsResponse = await datasquirel.get({ key: process.env.DATASQUIREL_API_KEY, db: process.env.DB_NAME, query: "select title,slug,excerpt,date_created from blog_posts limit 10", }); const posts = postsResponse?.success ? postsResponse.payload : []; //* Main Function Return ///////////////////////////////////////////// return (

My Blog

{posts.map( ( post: { slug: string; title: string; excerpt: string; date_created: string; }, index: number ) => (

{post.title}

{post.excerpt} {post.date_created.substring(0, 24)}
) )}
); /** ********************************************** */ }