您期望从 Drupal 获得的一切。
在现代化的技术栈上。
实现无头化,无需牺牲功能。
无缝编辑
在编辑界面中内置了内联预览。
即时发布
新的内容和更新会立即生效。
多站点
通过一个 Drupal 网站为多个 Next.js 网站提供支持。
身份验证
支持角色和权限的身份验证。
Web 表单
由 Webform 模块支持的内置 React 表单。
搜索 API
支持由 Search API 提供支持的解耦分面搜索。
国际化
内置翻译和自动语言检测。
性能
通过内容交付网络部署和扩展您的网站。
安全
通过将代码与界面分离来保护您的网站免受攻击。
开箱即用的工具,带来最佳的开发体验
一个强大的 JSON:API 客户端。
// Create a DrupalClient.
const drupal = new DrupalClient("http://drupal.org", {
auth: {} // Authentication
fetcher: {} // Custom fetcher
cache: {} // Cache support
serializer: {} // Custom serializer
})
// Fetch an article.
const article = await drupal.getResource(
"node--article",
"907034d4-ab35-4949-84e4-d2b7afed82df"
)
// Create an article
const article = await drupal.createResource("node--article", {
attributes: {
title: "Title of Article",
body: {
value: "<p>Content of body field</p>",
format: "full_html",
},
},
})
// Fetch an article.
const article = await drupal.getResource(
"node--article",
"907034d4-ab35-4949-84e4-d2b7afed82df"
)
// Fetch a collection of terms.
const tags = await drupal.getResourceCollection("taxonomy_term--tags")
// Fetch a menu.
const main = await drupal.getMenu("main")
// Fetch a view.
const recentContent = await drupal.getView("content_recent--block")
// Use filters.
const sortedPublishArticles = await drupal.getResourceCollection(
"node--article",
{
params: {
"filter[status]": "1",
sorted: "-created",
},
}
)
// Create an article.
const article = await drupal.createResource("node--article", {
attributes: {
title: "Title of Article",
body: {
value: "<p>Content of body field</p>",
format: "full_html",
},
},
})
// Update article.
const article = await drupal.updateResource(
"node--article",
"a937dd34-5407-4fff-8594-fccaaa5bb72a",
{
data: {
attributes: {
title: "Title of Article",
},
},
}
)
// Delete article.
const deleted = await drupal.deleteResource(
"node--article",
"a937dd34-5407-4fff-8594-fccaaa5bb72a"
)
// Get the `es` translation for a page by uuid.
const page = await drupal.getResource(
"node--page",
"07464e9f-9221-4a4f-b7f2-01389408e6c8",
{
locale: "es",
defaultLocale: "en",
}
)
// Fetch a collection of translated articles.
const articles = await drupal.getResourceCollection("node--article", {
locale: "es",
defaultLocale: "en",
})
// Fetch translated menu items.
const main = await drupal.getMenu("main", {
locale: "es",
defaultLocale: "en",
})
// Bearer token.
export const drupal = new DrupalClient(
process.env.NEXT_PUBLIC_DRUPAL_BASE_URL,
{
auth: {
clientId: process.env.DRUPAL_CLIENT_ID,
clientSecret: process.env.DRUPAL_CLIENT_SECRET,
},
}
)
// Basic.
export const drupal = new DrupalClient(
process.env.NEXT_PUBLIC_DRUPAL_BASE_URL,
{
auth: {
username: process.env.DRUPAL_USERNAME,
password: process.env.DRUPAL_PASSWORD,
},
}
)
// Bring your own.
export const drupal = new DrupalClient(
process.env.NEXT_PUBLIC_DRUPAL_BASE_URL,
{
auth: () => {
// Do something and return an Authorization header.
},
}
)
// DrupalNode
const article = await drupal.getResource<DrupalNode>(
"node--article",
"907034d4-ab35-4949-84e4-d2b7afed82df"
)
// DrupalTaxonomyTerm
const tags = await drupal.getResourceCollection<DrupalTaxonomyTerm[]>(
"taxonomy_term--tags"
)
// Any resource type.
const resources = await drupal.getResourceCollection<JsonApiResource[]>(
"entity--bundle"
)
const data = await query({
query: `
query {
nodeArticles(first: 10) {
nodes {
id
title
path
author {
displayName
}
body {
processed
}
created
image {
width
url
height
}
}
}
}
`,
})