今日已更新 80 条资讯 | 累计 20052 条内容
关于我们

标签:#sanity

找到 5 篇相关文章

AI 资讯

Sanity vs Directus for Next.js in 2026: An Honest Comparison

Sanity vs Directus is a comparison that comes up more than you'd expect on technical forums in 2026, usually from teams who already have a Postgres database running and are wondering why they'd pay for a separate content lake when Directus can wrap what they have. It's a fair question. These two tools solve adjacent problems but from genuinely different starting points, and the right choice depends heavily on whether your content is primarily relational data or editorial content. What each tool actually is Sanity is a hosted content platform. Your content lives in Sanity's managed "content lake" — a document store with real-time collaboration, a CDN-backed asset pipeline, and GROQ as the query language. You define schemas in code, deploy a customisable Studio, and talk to Sanity's API from your Next.js app. You do not manage infrastructure. Directus is an open-source data platform that wraps any existing SQL database — Postgres, MySQL, SQLite, MS SQL — and exposes it through a REST API, a GraphQL endpoint, and a web-based admin UI. Schema changes happen in the admin UI (or via migrations), and your data stays in your own database. You can self-host entirely or use Directus Cloud. That distinction — hosted content lake vs database-wrapper — drives nearly every practical difference between them. Data ownership and where your content lives With Sanity, your content lives in Sanity's infrastructure. You can export it via the export API, but you are operationally dependent on Sanity's uptime and their CDN. For most product teams that's fine — Sanity has been reliable and their SLA on Growth/Enterprise tiers is solid. But if you're in a regulated industry, have strict data residency requirements, or your client contract requires them to own the database, it's a real constraint. With Directus, the database is yours from day one. You point Directus at a Postgres instance on your own infrastructure (or a managed one like Supabase, Neon, or Railway), and Directus adds the API

2026-07-15 原文 →
AI 资讯

How I add semantic search to a Next.js site using Sanity Embeddings

Sanity Embeddings semantic search in Next.js is one of those features that looks complicated from the outside but is surprisingly lean to wire up once you understand the moving parts. This post covers the current native Embeddings feature built into Sanity datasets — not the older Embeddings Index API, which Sanity is sunsetting. If you found a guide that talks about a separate embeddings-index resource you have to provision via the Management API, it is stale; skip it. What Sanity Embeddings actually is Sanity's native Embeddings feature lets you mark document types for vector indexing directly inside your dataset. Sanity handles the embedding model and the vector store; you never manage a separate service. Queries use a dedicated sanity.embeddings.query GROQ function that takes a natural-language string and returns documents ranked by semantic similarity. The feature is available on Growth and Enterprise plans as of mid-2026. The workflow has three parts: Configure which document types get indexed (dataset setting or the Embeddings pane in Sanity Studio). Run a semantic query from your Next.js route handler using the Sanity client. Render the results in a search UI component. Setting up the embeddings index in your dataset Go to Manage → your project → Embeddings (or open the Embeddings pane inside Sanity Studio if your plan surfaces it there). Create an index, give it a name (e.g. site_search ), and select which document types and fields to embed. For a blog you would typically pick post with fields title , excerpt , and body (plain text extracted from Portable Text). Sanity backfills existing documents automatically. New and updated documents are re-embedded on publish via an internal webhook — you do not configure that yourself. There is no code required for the indexing step. The index name you choose here ( site_search ) is what you will pass in the GROQ query. Querying embeddings from a Next.js route handler Create a route handler that accepts a search term,

2026-07-08 原文 →
AI 资讯

Every Sanity page builder has the same bug

Every Sanity marketing site ends up with a page builder. An array of sections, an insert menu, a render loop that maps block._type to a component. You've built it. I've built it. We've all built the same thing. And every one of them ships with the same bug. You add a new section. You wire it into the schema. You add a renderer. You add a component. You add the type. And then — because there are five places to touch and you're a human — you forget one. The section renders blank in production. Or it never shows up in the insert menu. Or it fetches no fields because you missed the GROQ projection, so it renders as nothing at all. No error. No red. Just a hole on the page where a section should be. The annoying part isn't the bug. It's that you'll hit it again on the next project, in exactly the same way, because you rewrote the whole thing from scratch — again. The section tax Here's what "add a section" actually costs in a typical Sanity + Next.js page builder: Schema — a new *Section object type, registered in your schema index. GROQ — a new conditional in the page-builder projection so the block's fields actually come down. Component — the React component that renders it. Renderer map — an entry mapping _type → component. Types — the block variant in whatever union your frontend renders. Miss #2 and the block arrives empty. Miss #4 and it silently skips. Miss #5 and TypeScript shrugs because your union is hand-maintained and now lies. Three different failure modes, all of them quiet, all of them "works on my machine until it doesn't." Now look at those five places and ask: which of them is actually unique to your site? The component is. It's welded to your design system — your spacing, your tokens, your brand. Nobody can reuse it and nobody should. The other four are plumbing . "Look up _type in a map, call the renderer, keep the map in sync with the schema and the query." That code is byte-for-byte the same idea on every project you've ever built. So why is it livi

2026-06-29 原文 →
AI 资讯

Contentful vs. Sanity vs. SleekCMS: A Practical Comparison for Developer Teams

Start here This post assumes you have a project and you're trying to pick a tool. It skips the marketing and goes to the technical and economic decisions that actually matter when you're doing the evaluation. All three of these platforms — Contentful, Sanity, and SleekCMS — are used in production by serious teams. The comparison is not going to tell you one of them is bad. It's going to tell you which scenarios each one is genuinely suited for, so you can match your project to the right tool. The three platforms at a glance Contentful is an enterprise-grade headless CMS with a long history of production deployments, a large ecosystem of integrations, and pricing that becomes significant at scale. It's the established choice for large organisations with existing Contentful investment. Sanity is a developer-first headless CMS with a flexible schema system, real-time collaborative editing, and GROQ — a query language purpose-built for content graphs. It has a strong developer community and a genuinely modern developer experience. SleekCMS is a headless CMS with an integrated static site builder. Structured content with REST and GraphQL APIs, a TypeScript-native client library, and the option to generate and deploy a static site from the same content models without maintaining an external frontend stack. Content modeling All three support structured content modeling. The differences are in how you define models and what the system supports natively. Contentful uses a GUI-based model builder in the dashboard. You create content types and add fields through a point-and-click interface. Solid for teams who prefer a visual setup; less ideal if you want models version-controlled as code. Sanity defines schemas in TypeScript or JavaScript config files — committed to your repository, version-controlled, and composable like code. This is Sanity's strongest differentiator for teams who think in code-first workflows. The schema definition is expressive and the TypeScript integrat

2026-06-07 原文 →