### Install dependencies Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/getting-started.mdx Install the necessary project dependencies. ```bash npm install ``` -------------------------------- ### Navigate to admin panel Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/getting-started.mdx Access the EmDash admin panel to start the setup wizard. ```bash http://localhost:4321/_emdash/admin ``` -------------------------------- ### Start the dev server Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/getting-started.mdx Run the development server to preview your site. ```bash npm run dev ``` -------------------------------- ### Install Dependencies and Start Dev Server Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/themes/creating-themes.mdx After creating a test project, navigate into the project directory and install its dependencies. Then, start the local development server to preview your theme. ```bash cd test-site npm install npm run dev ``` -------------------------------- ### plugin:install Hook Example Source: https://github.com/emdash-cms/emdash/blob/main/skills/creating-plugins/references/hooks.md Example of the `plugin:install` hook, used for seeding default values and storage items. ```typescript "plugin:install": async (_event, ctx) => { await ctx.kv.set("settings:enabled", true); await ctx.storage.items!.put("default", { name: "Default" }); } ``` -------------------------------- ### Start the demo Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/contributing/index.mdx Starts the simple demo project. The setup wizard runs automatically on first launch. ```bash cd demos/simple pnpm dev ``` -------------------------------- ### Query Content in Astro Pages (Collection) Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/getting-started.mdx Example of fetching multiple posts using getEmDashCollection in an Astro page. ```astro --- import { getEmDashCollection } from "emdash"; import Base from "../layouts/Base.astro"; const { entries: posts } = await getEmDashCollection("posts"); ---

Latest Posts

``` -------------------------------- ### plugin:install Hook Example Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/reference/hooks.mdx Example of the `plugin:install` hook to initialize default settings and log success. ```typescript hooks: { "plugin:install": async (event, ctx) => { // Initialize default settings await ctx.kv.set("settings:enabled", true); await ctx.kv.set("settings:threshold", 100); ctx.log.info("Plugin installed successfully"); }, } ``` -------------------------------- ### Project Structure Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/getting-started.mdx Overview of the EmDash project directory structure. ```bash my-emdash-site/ ├── astro.config.mjs # Astro + EmDash configuration ├── src/ │ ├── live.config.ts # Live Collections configuration │ ├── pages/ │ │ ├── index.astro # Homepage │ │ └── posts/ │ │ └── [...slug].astro # Dynamic post pages │ ├── layouts/ │ │ └── Base.astro # Base layout │ └── components/ # Your Astro components ├── .emdash/ │ ├── seed.json # Template seed file │ └── types.ts # Generated TypeScript types └── package.json ``` -------------------------------- ### Query Content in Astro Pages (Single Entry) Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/getting-started.mdx Example of fetching a single post by slug using getEmDashEntry in an Astro page. ```astro --- import { getEmDashEntry } from "emdash"; const { slug } = Astro.params; const { entry: post } = await getEmDashEntry("posts", slug); if (!post) { return Astro.redirect("/404"); } ---

{post.data.title}

``` -------------------------------- ### Navigate to your project directory Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/getting-started.mdx Change directory into your newly created EmDash project. ```bash cd my-emdash-site ``` -------------------------------- ### Run the EmDash Demo Source: https://github.com/emdash-cms/emdash/blob/main/demos/plugins-demo/README.md Commands to install dependencies, seed sample content, and start the development server. ```bash # Install dependencies pnpm install # Seed sample content pnpm seed # Start development server pnpm dev # Open browser open http://localhost:4321 ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/emdash-cms/emdash/blob/main/CONTRIBUTING.md Clone the EmDash repository and install project dependencies using pnpm. This is the initial setup step. ```bash git clone https://github.com/emdash-cms/emdash.git && cd emdash pnpm install pnpm build # required before first run ``` -------------------------------- ### Code sample introduction Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/contributing/docs-style-guide.mdx Example of a good introduction for a code block. ```markdown ✅ The following example registers a plugin in the `sandboxed` array: ``` -------------------------------- ### Create a New Project Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/getting-started.mdx Use npm, pnpm, or yarn to create a new EmDash project. ```bash npm create emdash@latest ``` ```bash pnpm create emdash@latest ``` ```bash yarn create emdash ``` -------------------------------- ### plugin:install hook example Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/plugins/creating-plugins/hooks.mdx Example of a plugin:install hook that sets a value in KV storage and puts an item into storage. ```typescript "plugin:install": async (_event, ctx) => { ctx.log.info("Installing plugin..."); await ctx.kv.set("settings:enabled", true); await ctx.storage.items.put("default", { name: "Default Item" }); } ``` -------------------------------- ### Initialize an EmDash Template Source: https://github.com/emdash-cms/emdash/blob/main/TEMPLATES.md Commands to copy a template, install dependencies, seed the database, and start the development server. ```bash # Copy the template you want cp -r templates/blog my-site cd my-site # Install dependencies pnpm install # Initialize the database and seed demo content pnpm bootstrap # Start the dev server pnpm dev ``` -------------------------------- ### plugin:install Source: https://github.com/emdash-cms/emdash/blob/main/skills/creating-plugins/references/hooks.md Runs once on first install. Use to seed defaults. ```APIDOC ## plugin:install ### Description Runs once on first install. Use to seed defaults. ### Event `{}` ### Returns `void` ### Example ```typescript "plugin:install": async (_event, ctx) => { await ctx.kv.set("settings:enabled", true); aawait ctx.storage.items!.put("default", { name: "Default" }); } ``` ``` -------------------------------- ### Post-Scaffolding Commands Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/themes/overview.mdx After scaffolding, install dependencies and start the dev server: ```bash cd my-site npm install npm run dev ``` -------------------------------- ### Plugin runtime isolation example Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/contributing/docs-style-guide.mdx Demonstrates how plugins run in an isolated runtime and can only access declared APIs. ```text ✅ Plugins run in an isolated runtime and can only reach the APIs they declare. ❌ Plugins live in a cosy little sandbox where nothing bad can ever happen! ``` -------------------------------- ### src/live.config.ts Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/getting-started.mdx Connects EmDash to Astro's content system via a single live collection. ```typescript import { defineLiveCollection } from "astro:content"; import { emdashLoader } from "emdash/runtime"; export const collections = { _emdash: defineLiveCollection({ loader: emdashLoader() }), }; ``` -------------------------------- ### Code sample introduction alternative Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/contributing/docs-style-guide.mdx Example of a bad introduction for a code block. ```markdown ❌ Add the plugin like so: ``` -------------------------------- ### Setup Status Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/reference/rest-api.mdx Returns whether setup is complete and if users exist. ```http GET /_emdash/api/setup/status ``` -------------------------------- ### Build a New Site in Monorepo Source: https://github.com/emdash-cms/emdash/blob/main/CONTRIBUTING.md Copy a template, update its package.json with a unique name, install dependencies, and start the development server. Core changes are reflected immediately due to workspace links. ```bash cp -r templates/blog demos/my-site # edit demos/my-site/package.json to set a unique name pnpm install cd demos/my-site && pnpm dev ``` -------------------------------- ### Install @astrojs/rss Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/guides/create-a-blog.mdx Command to install the @astrojs/rss package. ```bash npm install @astrojs/rss ``` -------------------------------- ### Install EmDash CLI Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/reference/cli.mdx Install the EmDash CLI package using npm. ```bash npm install emdash ``` -------------------------------- ### Global installation Source: https://github.com/emdash-cms/emdash/blob/main/packages/plugin-cli/README.md Install the plugin CLI globally and then initialize a new plugin. ```sh npm install -g @emdash-cms/plugin-cli emdash-plugin init my-plugin ``` -------------------------------- ### Override Preview Secret Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/getting-started.mdx Example of setting the EMDASH_PREVIEW_SECRET environment variable. ```bash EMDASH_PREVIEW_SECRET=your-preview-secret ``` -------------------------------- ### Set Encryption Key Environment Variable Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/getting-started.mdx Example of setting the EMDASH_ENCRYPTION_KEY environment variable. ```bash EMDASH_ENCRYPTION_KEY=emdash_enc_v1_... ``` -------------------------------- ### Static Rendering Example Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/guides/querying-content.mdx Example of using `getStaticPaths` with `getEmDashCollection` for static site generation. ```astro --- import { getEmDashCollection, getEmDashEntry } from "emdash"; export async function getStaticPaths() { const { entries: posts } = await getEmDashCollection("posts", { status: "published", }); return posts.map((post) => ({ params: { slug: post.data.slug }, })); } const { slug } = Astro.params; const { entry: post } = await getEmDashEntry("posts", slug); --- ``` -------------------------------- ### Run Simple Demo Locally Source: https://github.com/emdash-cms/emdash/blob/main/CONTRIBUTING.md Navigate to the simple demo directory and start the development server. This demo uses Node.js and SQLite. ```bash cd demos/simple pnpm dev # http://localhost:4321 ``` -------------------------------- ### Start development and testing Source: https://github.com/emdash-cms/emdash/blob/main/packages/marketplace/README.md Commands to initiate the local development server and execute the test suite. ```bash pnpm dev # starts wrangler dev server on :8787 pnpm test # runs vitest ``` -------------------------------- ### Install the AWS SDK Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/deployment/storage.mdx Install the necessary AWS SDK packages for S3 adapter. ```sh pnpm add @aws-sdk/client-s3 @aws-sdk/s3-request-presigner ``` -------------------------------- ### Get Content Response Example Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/reference/rest-api.mdx Example response for retrieving a single content item. ```json { "success": true, "data": { "item": { "id": "01HXK5MZSN...", "type": "posts", "slug": "hello-world", "data": { "title": "Hello World", ... }, "status": "published", "createdAt": "2025-01-24T12:00:00Z", "updatedAt": "2025-01-24T12:00:00Z" } } } ``` -------------------------------- ### Start EmDash Dev Server Source: https://github.com/emdash-cms/emdash/blob/main/demos/cloudflare/README.md Run this command to start the development server. EmDash handles migrations automatically on the first request. ```bash pnpm dev ``` -------------------------------- ### WordPress Options API example Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/migration/porting-plugins.mdx Example of using WordPress's Options API to get, update, and delete options. ```php $api_key = get_option('my_plugin_api_key', ''); update_option('my_plugin_api_key', 'abc123'); delete_option('my_plugin_api_key'); ``` -------------------------------- ### Expressive Code diff example Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/contributing/docs-style-guide.mdx Example of using Expressive Code annotations for before/after changes, showing a single line change. ```markdown ```ts del={1} ins={2} import { definePlugin } from "emdash"; import type { SandboxedPlugin } from "emdash/plugin"; ``` ``` -------------------------------- ### Build and Run Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/deployment/nodejs.mdx Commands to build the project and start the Node.js server. ```bash npm run build node ./dist/server/entry.mjs ``` -------------------------------- ### Bundle, Login, and Publish Plugin Source: https://github.com/emdash-cms/emdash/blob/main/skills/creating-plugins/SKILL.md Use EmDash CLI commands to bundle your plugin into a distributable format, authenticate with the marketplace, and publish your plugin. Ensure your plugin is correctly bundled before publishing. ```bash emdash plugin bundle --dir packages/plugins/my-plugin # creates .tar.gz emdash plugin login # authenticate via GitHub emdash plugin publish --tarball dist/my-plugin-1.0.0.tar.gz ``` -------------------------------- ### Where clause operators - Starts with Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/plugins/creating-plugins/storage.mdx Example of using the 'startsWith' operator in the where clause for querying. ```typescript where: { slug: { startsWith: "blog-" }, } ``` -------------------------------- ### Handling HTTP Methods Source: https://github.com/emdash-cms/emdash/blob/main/skills/creating-plugins/references/api-routes.md Example of how to handle different HTTP methods within a single route handler by checking `ctx.request.method`. Includes examples for GET and DELETE, with a fallback for unsupported methods. ```typescript handler: async (ctx) => { switch (ctx.request.method) { case "GET": return await ctx.storage.items!.get(ctx.input.id); case "DELETE": await ctx.storage.items!.delete(ctx.input.id); return { deleted: true }; default: throw new Response("Method not allowed", { status: 405 }); } }; ``` -------------------------------- ### EmDash KV Store example Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/migration/porting-plugins.mdx Example of using EmDash's KV store to get, set, and delete values, analogous to WordPress Options API. ```typescript const apiKey = await ctx.kv.get("settings:apiKey") ?? ""; await ctx.kv.set("settings:apiKey", "abc123"); await ctx.kv.delete("settings:apiKey"); ``` -------------------------------- ### Complete Example Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/guides/preview.mdx A full blog post template combining preview and visual editing support. ```astro --- import { getEmDashEntry } from "emdash"; import BaseLayout from "../../layouts/Base.astro"; import { PortableText } from "emdash/ui"; const { slug } = Astro.params; // Preview is automatic — middleware handles token verification const { entry, isPreview, error } = await getEmDashEntry("posts", slug); if (error) { return new Response("Server error", { status: 500 }); } if (!entry) { return Astro.redirect("/404"); } --- {isPreview && ( )}

{entry.data.title}

{entry.data.publishedAt && ( )} {isPreview && !entry.data.publishedAt && ( Draft )}
``` -------------------------------- ### src/plugin.ts Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/plugins/creating-plugins/storage.mdx Example of using the storage API in a sandboxed plugin to put and get data. ```typescript import type { SandboxedPlugin } from "emdash/plugin"; export default { hooks: { "content:afterSave": { handler: async (event, ctx) => { const { submissions } = ctx.storage; await submissions.put("sub_123", { formId: "contact", email: "user@example.com", status: "pending", createdAt: new Date().toISOString(), }); const item = await submissions.get("sub_123"); ctx.log.info("Stored submission", { id: item?.formId }); }, }, }, } satisfies SandboxedPlugin; ``` -------------------------------- ### Generate Encryption Key Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/getting-started.mdx Command to generate an encryption key for plugin secrets. ```bash npx emdash secrets generate ``` -------------------------------- ### File-based code sample Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/contributing/docs-style-guide.mdx Example of adding a `title=` filename to a code block. ```markdown ```ts title="src/plugin.ts" ``` ``` -------------------------------- ### Storage Index Configuration Example Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/plugins/creating-plugins/manifest.mdx Example JSONC showing how to configure indexes for a storage collection. ```jsonc "storage": { "events": { "indexes": ["timestamp", ["collection", "timestamp"]] } } ``` -------------------------------- ### Start EmDash Development Server Source: https://github.com/emdash-cms/emdash/blob/main/infra/cache-demo/AGENTS.md Use this command to start the development server. It also runs migrations, seeds the database, and generates TypeScript types. ```bash npx emdash dev ``` -------------------------------- ### Initialize Performance Monitor - JavaScript Source: https://github.com/emdash-cms/emdash/blob/main/infra/perf-monitor/public/index.html Sets up the performance monitor by loading configuration, applying initial hash state, refreshing data, and attaching event listeners for user interactions and hash changes. Includes an interval for auto-refreshing data. ```javascript async function init() { try { await loadConfig(); applyHashToSelects(); writeHashFromSelects(); await refresh(); const syncAndRefresh = () => { writeHashFromSelects(); refresh(); }; document.getElementById("site-select").addEventListener("change", () => { updateTargetLabel(); syncAndRefresh(); }); document.getElementById("route-select").addEventListener("change", syncAndRefresh); document.getElementById("region-select").addEventListener("change", syncAndRefresh); document.getElementById("period-select").addEventListener("change", syncAndRefresh); // Reflect external hash changes (manual edit, back/forward). window.addEventListener("hashchange", () => { applyHashToSelects(); refresh(); }); // Auto-refresh every 5 minutes setInterval(refresh, 5 * 60 * 1000); } catch (err) { document.querySelector(".container").innerHTML = `
Failed to load: ${err.message}
`; } } init(); ``` -------------------------------- ### Get Terms for an Entry Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/guides/taxonomies.mdx Examples of retrieving all categories and tags assigned to a specific content entry. ```typescript import { getEntryTerms } from "emdash"; // Get all categories for a post const categories = await getEntryTerms("posts", "post-123", "category"); // Get all tags for a post const tags = await getEntryTerms("posts", "post-123", "tag"); ``` -------------------------------- ### Start Development Server Source: https://github.com/emdash-cms/emdash/blob/main/skills/emdash-cli/SKILL.md Start the local EmDash development server. It automatically runs migrations and applies the seed data if the database is empty. ```bash # Start dev server (runs migrations, applies seed on empty DB, starts Astro) npx emdash dev ``` ```bash # Start dev server and generate types from remote npx emdash dev --types ``` -------------------------------- ### Get All Terms Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/guides/taxonomies.mdx Examples of fetching all terms for 'category' and 'tag' taxonomies using the `getTaxonomyTerms` function. ```typescript import { getTaxonomyTerms } from "emdash"; // Get all categories (returns tree structure) const categories = await getTaxonomyTerms("category"); // Get all tags (returns flat list) const tags = await getTaxonomyTerms("tag"); ``` -------------------------------- ### Install Registry Client Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/plugins/registry-client.mdx Install the registry client package and pin it to an exact version. This command is for npm users. ```sh npm install @emdash-cms/registry-client@0.3.1 ``` -------------------------------- ### Get a Single Term Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/guides/taxonomies.mdx Example of fetching a single term by its taxonomy and slug using the `getTerm` function. ```typescript import { getTerm } from "emdash"; const category = await getTerm("category", "news"); // Returns TaxonomyTerm or null ``` -------------------------------- ### Run Portfolio Template Locally Source: https://github.com/emdash-cms/emdash/blob/main/CONTRIBUTING.md Navigate to the portfolio template directory and start its development server. Templates are runnable directly as workspace members. ```bash cd templates/portfolio pnpm dev ``` -------------------------------- ### Navigate Demo Site with Agent-Browser Source: https://github.com/emdash-cms/emdash/blob/main/skills/wordpress-theme-to-emdash/phases/1-discovery.md Commands to open a demo site and explore its structure using the agent-browser tool. ```bash agent-browser open https://demo-site.com # Click around to find different page types # Check the navigation menu for page links # Look for "View all posts" or category links ``` -------------------------------- ### astro.config.mjs Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/getting-started.mdx Configuration for registering EmDash as an Astro integration with local SQLite database and file storage. ```javascript import { defineConfig } from "astro/config"; import emdash, { local } from "emdash/astro"; import { sqlite } from "emdash/db"; export default defineConfig({ integrations: [ emdash({ database: sqlite({ url: "file:./data.db" }), storage: local({ directory: "./uploads", baseUrl: "/_emdash/api/media/file", }), }), ], }); ``` -------------------------------- ### Install a Theme from npm Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/themes/creating-themes.mdx Users can install your published theme by specifying its npm package name with the `npm create astro` command. ```bash npm create astro@latest -- --template @your-org/emdash-theme-blog ``` -------------------------------- ### Bundle and publish plugins via CLI Source: https://github.com/emdash-cms/emdash/blob/main/skills/creating-plugins/references/publishing.md Use these commands to bundle, inspect, and publish plugins to the marketplace. ```bash # Bundle only (inspect first) emdash plugin bundle tar tzf dist/my-plugin-1.0.0.tar.gz # Publish (uploads to marketplace) emdash plugin publish # Build + publish in one step emdash plugin publish --build ``` -------------------------------- ### Taxonomies Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/coming-from/wordpress.mdx Examples of getting taxonomy terms and specific terms using EmDash functions. ```typescript import { getTaxonomyTerms, getEntryTerms, getTerm } from "emdash"; // Get all categories const categories = await getTaxonomyTerms("categories"); // Get a specific term const news = await getTerm("categories", "news"); // Get terms for a post const postCategories = await getEntryTerms("posts", postId, "categories"); ``` -------------------------------- ### Key Naming Conventions Example Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/plugins/creating-plugins/settings.mdx Example illustrating the use of prefixes for organizing data in the KV store and avoiding bare keys. ```typescript // Clear prefixes await ctx.kv.set("settings:webhookUrl", url); await ctx.kv.set("state:lastRun", timestamp); await ctx.kv.set("cache:feed", feedData); // Avoid bare keys await ctx.kv.set("url", url); ``` -------------------------------- ### Detected content example Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/migration/from-wordpress.mdx Example output from the import wizard showing detected content types and counts. ```text Found in export: ├── Posts: 127 → posts [New collection] ├── Pages: 12 → pages [Add fields] └── Media: 89 attachments ``` -------------------------------- ### Response for Get Content Items Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/reference/rest-api.mdx Example JSON response structure when retrieving content items. ```json { "success": true, "data": { "items": [ { "id": "01HXK5MZSN...", "collection": "posts", "entryId": "01HXK5MZSN...", "data": { ... }, "createdAt": "2025-01-24T12:00:00Z" } ], "total": 5 } } ``` -------------------------------- ### Get Section API Endpoint Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/guides/sections.mdx Example of how to fetch a single section by its slug using the REST API. ```http GET /_emdash/api/sections/newsletter-cta ``` -------------------------------- ### Setting default values for settings Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/plugins/creating-plugins/settings.mdx This TypeScript code snippet demonstrates how to provide default values for settings that are read from KV storage. It shows using the nullish coalescing operator (`??`) to set defaults at the read site. It also includes an example of persisting defaults during plugin installation using the `plugin:install` hook. ```typescript const enabled = (await ctx.kv.get("settings:enabled")) ?? true; const maxItems = (await ctx.kv.get("settings:maxItems")) ?? 100; ``` ```typescript hooks: { "plugin:install": async (_event, ctx) => { await ctx.kv.set("settings:enabled", true); await ctx.kv.set("settings:maxItems", 100); }, }, ``` -------------------------------- ### Quick Start Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/index.mdx Commands to create a new EmDash site and start the development server. ```bash npm create astro@latest -- --template @emdash-cms/template-blog npm run dev ``` -------------------------------- ### Build and Seed Main Harness Source: https://github.com/emdash-cms/emdash/blob/main/scripts/query-dumps/README.md Execute this command to build and seed the main harness, preparing the environment for query analysis. ```bash node scripts/query-counts.mjs --target sqlite ``` -------------------------------- ### MinIO configuration example Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/deployment/storage.mdx Configuration for using the S3 adapter with a MinIO instance, including endpoint, bucket, and credentials. ```js storage: s3({ endpoint: "https://minio.example.com", bucket: "emdash-media", accessKeyId: process.env.MINIO_ACCESS_KEY, secretAccessKey: process.env.MINIO_SECRET_KEY, publicUrl: "https://minio.example.com/emdash-media", }); ``` -------------------------------- ### Upgrade and migration guide structure Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/contributing/docs-style-guide.mdx Structure for a guide that helps a reader move an existing project to a new version. ```markdown ```md ### [Renamed/Changed/Removed/Deprecated]: In earlier versions, . . #### What should I do? ``` ``` -------------------------------- ### KV Store Usage Examples Source: https://github.com/emdash-cms/emdash/blob/main/skills/creating-plugins/references/storage.md Demonstrates setting key-value pairs in the KV store and listing keys with a specific prefix. Follow naming conventions for different purposes. ```typescript await ctx.kv.set("settings:webhookUrl", url); await ctx.kv.set("state:lastRun", new Date().toISOString()); const allSettings = await ctx.kv.list("settings:"); ``` -------------------------------- ### Ordering example Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/plugins/creating-plugins/storage.mdx Examples of specifying order for query results. ```typescript orderBy: { createdAt: "desc" } // newest first orderBy: { score: "asc" } // lowest first ``` -------------------------------- ### Run EmDash Demo Site Source: https://github.com/emdash-cms/emdash/blob/main/README.md Start the EmDash demo site, which uses Node.js and SQLite, requiring no Cloudflare account. This is useful for local development and testing. ```bash pnpm --filter emdash-demo seed pnpm --filter emdash-demo dev ``` -------------------------------- ### Run Setup and Create Dev Admin Session Source: https://github.com/emdash-cms/emdash/blob/main/AGENTS.md Use this endpoint in development to run migrations, create a dev admin user, establish a session, and redirect to the admin page. This is only available when `import.meta.env.DEV` is true. ```typescript await page.goto("http://localhost:4321/_emdash/api/setup/dev-bypass?redirect=/_emdash/admin"); ``` -------------------------------- ### Install Field Kit Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/plugins/field-kit.mdx Install the package from npm. ```bash npm i @emdash-cms/plugin-field-kit ``` -------------------------------- ### Bundle and Publish Marketplace Plugin Source: https://github.com/emdash-cms/emdash/blob/main/packages/plugins/marketplace-test/README.md Use these commands to bundle and publish the marketplace test plugin to a registry. Ensure you have the correct directory and tarball path. ```bash emdash plugin bundle --dir packages/plugins/marketplace-test emdash plugin publish dist/marketplace-test-0.1.0.tar.gz --registry https://emdash-marketplace.cto.cloudflare.dev ``` -------------------------------- ### Start EmDash Dev Server and Generate Types Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/reference/cli.mdx Starts the EmDash development server and generates TypeScript types from a remote instance before starting. Ensures type safety during development. ```bash npx emdash dev --types ``` -------------------------------- ### Preview Mode Example Source: https://github.com/emdash-cms/emdash/blob/main/docs/src/content/docs/guides/querying-content.mdx Example of using `getEmDashEntry` in Astro, demonstrating automatic preview handling. ```astro --- import { getEmDashEntry } from "emdash"; const { slug } = Astro.params; // No special preview handling needed — middleware does it automatically const { entry, isPreview, error } = await getEmDashEntry("posts", slug); if (error) { return new Response("Server error", { status: 500 }); } if (!entry) { return Astro.redirect("/404"); } --- {isPreview && (
Viewing preview. This content is not published.
)}

{entry.data.title}

```