-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsanity.blueprint.ts
More file actions
47 lines (46 loc) · 1.26 KB
/
sanity.blueprint.ts
File metadata and controls
47 lines (46 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import {defineBlueprint, defineDocumentFunction} from "@sanity/blueprints";
export default defineBlueprint({
resources: [
defineDocumentFunction({
type: "sanity.function.document",
name: "find-resources",
src: "./functions/find-resources",
memory: 2,
timeout: 30,
event: {
on: ["publish"],
filter: "_type == 'newsletter'",
projection: '{_id, "sourceText": body}',
},
}),
defineDocumentFunction({
type: "sanity.function.document",
name: "get-linked-data",
src: "./functions/get-linked-data",
memory: 2,
timeout: 30,
event: {
on: ["update", "create"],
includeDrafts: true,
includeAllVersions: true,
filter:
`_type == 'resource'
&& (
delta::changedAny(ldMetadata.ldLastRequested)
|| (
!defined(before().ldMetadata.ldLastRequested)
&& defined(after().ldMetadata.ldLastRequested)
)
|| (
delta::operation() == 'create'
&& defined(resourceUrl)
)
)
&& ldMetadata.ldIsUpdating != true
`,
projection:
"{_id, title, 'url':resourceUrl}",
},
}),
],
});