--- import type { CollectionEntry } from 'astro:content'; import BaseHead from '../components/BaseHead.astro'; import Header from '../components/Header.astro'; import Footer from '../components/Footer.astro'; import FormattedDate from '../components/FormattedDate.astro'; import StarRating from '../components/StarRating.astro' import { getSlugForNote, getTypeForNote, getNotes } from '../components/Notes.astro'; // console.log("IndexPage.astro: Astro.props=", Astro.props) let { title, description, heroImage } = Astro.props; // const filePath = Astro.props.file || ""; const slug = getSlugForNote(Astro.props) const type = getTypeForNote(Astro.props) title = type function hasReview(note) { return note.props.rawContent().trim().length > 0; } const notes = await getNotes({ keepIf: (note) => note.params.type === type && !/readme.md$/.test(note.props.file) }); // TODO: Create separate maps for [san-francisco, new-york], use that to also generate the filenames let locationString = ''; notes.slice(0, 9).forEach((note, index) => { if (note.props.frontmatter?.location) { locationString += `&markers=label:${index+1}%7C${note.props.frontmatter.location.join(',')}`; } if (note.props.frontmatter?.locations) { locationString += `&markers=label:${index+1}%7C${note.props.frontmatter.locations.map(l=>l.join(',')).join('|')}`; } }); if (locationString.length > 0) { import path from 'path'; import fs from "fs/promises"; const url = `https://maps.googleapis.com/maps/api/staticmap?size=800x600&maptype=roadmap&key=${import.meta.env.SECRET_GOOGLE_MAPS_API_KEY}&markers=${locationString}`; const response = await fetch(url); const blob = await response.blob(); const data = new Uint8Array(await blob.arrayBuffer()); const filename = `map-${type}-san-francisco.png`; // TODO: should this write directly into dist? Or should that happen in a build:done hook like here: https://github.com/LyonSyonII/astro-preload/blob/main/index.ts ["dist", "public"].forEach(async (dir) => { await fs.mkdir(dir, { recursive: true }); await fs.writeFile(path.join(process.cwd(), dir, filename), data); }); console.log(`Image from ${url} downloaded and saved to ${filename} in (dist and public)`); } ---
{heroImage && }

There are {notes.length} {type}:
{locationString.length === 0 && ( // If there's no map, show one long list
    {notes.map((note) => (
  1. {note.params.isDraft === 'true' && 🚧} {note.props.frontmatter.title} {type === 'books' && - {note.props.frontmatter?.author}} {type === 'books' && } {type === 'books' && "Finished on: "}{note.params.pubDate} {(type === 'books' && hasReview(note)) && 📝}
  2. ))}
)} {locationString.length > 0 && ( // If there are locations, show recent posts, a map of them, and then the rest
    {notes.slice(0, 9).map((note) => (
  1. {note.params.isDraft === 'true' && 🚧} {note.props.frontmatter.title} {type === 'books' && - {note.props.frontmatter?.author}} {type === 'books' && } {type === 'books' && "Finished on: "}{note.params.pubDate} {(type === 'books' && hasReview(note)) && 📝}
  2. ))}
    {notes.slice(9).map((note) => (
  • {note.params.isDraft === 'true' && 🚧} {note.props.frontmatter.title} {type === 'books' && - {note.props.frontmatter?.author}} {type === 'books' && } {type === 'books' && "Finished on: "}{note.params.pubDate} {(type === 'books' && hasReview(note)) && 📝}
  • ))}

)}
{
Last updated on
}