Getting Started
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
An opinionated Starlight plugin to create a recipe website.
Starlight Recipes supports the following features:
- Paginated recipe browsing and discovery
- Global and per-recipe author attribution
- High-resolution cover image support
- Custom sidebar with featured content
- Cooking mode: Integrated timers and checkboxes
- Dynamic ingredient scaling by serving size
- Print-optimized layouts for every recipe
- Automated SEO via recipe structured data
The following features are available when you allow on-demand rendering:
- Automatic rating system based on Countify
Check out the demo for a preview of an example cookbook.
Prerequisites
Section titled “Prerequisites”You will need to have a Starlight website set up. If you don’t have one yet, you can follow the “Getting Started” guide in the Starlight docs to create one.
Installation and setup
Section titled “Installation and setup”-
Starlight Recipes is a Starlight plugin. Install it by running the following command in your terminal:
Terminal-Fenster npm install starlight-recipesTerminal-Fenster pnpm add starlight-recipesTerminal-Fenster yarn add starlight-recipes -
Configure the plugin in your Starlight configuration in the
astro.config.mjsfile.astro.config.mjs import starlight from '@astrojs/starlight'import { defineConfig } from 'astro/config'import starlightRecipes from 'starlight-recipes'export default defineConfig({integrations: [starlight({plugins: [starlightRecipes()],title: 'My Docs',}),],}) -
Starlight Recipes uses Astro’s content collections, which are configured in the
src/content.config.tsfile.Update the content config file to add support for customizing individual recipes using their frontmatter:
src/content.config.ts import { defineCollection } from 'astro:content';import { docsLoader } from '@astrojs/starlight/loaders';import { docsSchema } from '@astrojs/starlight/schema';import { recipesSchema } from 'starlight-recipes/schema'export const collections = {docs: defineCollection({loader: docsLoader(),schema: docsSchema({extend: (context) => recipesSchema(context)})}),};If you are already extending Starlight’s schema with additional fields, you can rely on Zod’s API to compose schemas together, e.g.
recipesSchema(context).merge(mySchema). -
Add Astro’s
siteconfiguration to enable Structured Data. This is necessary to generate valid SEO images.astro.config.mjs import starlight from '@astrojs/starlight'import { defineConfig } from 'astro/config'import starlightRecipes from 'starlight-recipes'export default defineConfig({site: "https://example.com",integrations: [starlight({plugins: [starlightRecipes()],title: 'My Docs',}),],}) -
Add any Astro Server Adapter to unlock interactive features.
Terminal-Fenster npx astro add cloudflareTerminal-Fenster npx astro add netlifyTerminal-Fenster npx astro add nodeTerminal-Fenster npx astro add vercelTerminal-Fenster pnpm astro add cloudflareTerminal-Fenster pnpm astro add netlifyTerminal-Fenster pnpm astro add nodeTerminal-Fenster pnpm astro add vercelTerminal-Fenster yarn astro add cloudflareTerminal-Fenster yarn astro add netlifyTerminal-Fenster yarn astro add nodeTerminal-Fenster yarn astro add vercel -
Create your first recipe by copying the recipe’s cover image into a new project folder, like
src/assets/, and creating a.mdor.mdxfile in thesrc/content/docs/recipes/directory:src/content/docs/recipes/virgin-colada.md ---title: Virgin Coladacover:alt: A tall glass of Virgin Colada with a pineapple wedge and cherryimage: "../../../assets/virgin-colada.png"--- -
Start the development server to preview the plugin in action.
The Starlight Recipes plugin behavior can be tweaked using various configuration options.