morally-bankrupt-books

A docs site used as an e-commerce platform 🤷‍♂️

Stars
0
Committers
1

Morally Bankrupt Books 😈📚

Trade your soul for free copies of free e-books.

Built for the Web Dev Challenge Hackathon #3 (E-comm Edition)

The app is a server-rendered Astro site, and uses the Algolia DocSearch plugin for the Starlight theme.

How It Works

Adding Books

To add books written in markdown you will need to add the required frontmatter for the docs content collection in Starlight. Run md-titles.py from /scripts in the directory of the markdown files you wish to add the frontmatter to. It will add a Title property based on the file name.

Selling Your Soul

The app uses nanostores to share state between Button.astro and EbookCard.astro.

This provides a kind of fake route protection for the demostrative purposes of this hackathon.

But! You could add persistence, middleware, and a payment provider to essentially make an e-commerce site with a built in e-reader.

Setting Up Algolia DocSearch

  1. Configure Astro SSR
  2. Deploy your app to your desired provider (this project uses Vercel)
  3. Use your production link to apply for DocSearch
  4. Add Algolia to Starlight

[!CAUTION] Algolia appId, apiKey, and indexName are safe to use client-side. write and admin stay secret.

Running Astro/Starlight

All commands are run from the root of the project, from a terminal:

Command Action
pnpm install Installs dependencies
pnpm run dev Starts local dev server at localhost:4321
pnpm run build Build your production site to ./dist/
pnpm run preview Preview your build locally, before deploying
pnpm run astro ... Run CLI commands like astro add, astro check
pnpm run astro -- --help Get help using the Astro CLI

Check out Starlight’s docs, read the Astro documentation, or jump into the Astro Discord server.


References