sanity-plugin-graph-view 1.0.4 → 3.0.0-studio-v3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ > **NOTE**
2
+ >
3
+ > This is the **Sanity Studio v3 version** of sanity-plugin-graph-view.
4
+ >
5
+ > For the v2 version, please refer to the [v2-branch](https://github.com/sanity-io/sanity-plugin-graph-view).
6
+
1
7
  <div align="center">
2
8
  <img src="assets/sanity-logo.png" width="177" alt="Sanity" />
3
9
  <h1>Graph View Plugin</h1>
@@ -9,47 +15,75 @@ Wonder how a visualization of your dataset will look? How many authors do you ha
9
15
 
10
16
  **Explore your data with this plugin, seek out strange corners and data types, boldly go where you could not before!**
11
17
 
12
- ```sh
13
- # In your Sanity Studio repository:
14
- sanity install graph-view
18
+ ## Installation
19
+
20
+
21
+ `npm install --save sanity-plugin-graph-view@studio-v3`
22
+
23
+ or
24
+
25
+ `yarn add sanity-plugin-graph-view@studio-v3`
26
+
15
27
 
16
- # Start the Studio
17
- sanity start
28
+ ## Usage
29
+
30
+ Add it as a plugin in sanity.config.ts (or .js):
31
+
32
+ ```js
33
+ import { contentGraphView } from "sanity-plugin-graph-view";
34
+
35
+ export default createConfig({
36
+ // ...
37
+ plugins: [
38
+ contentGraphView({}),
39
+ ]
40
+ })
18
41
  ```
19
42
 
43
+ This will add a /graph-your-content tools to the Sanity Studio, configured with this default query:
44
+ ```
45
+ *[
46
+ !(_id in path("_.*")) &&
47
+ !(_type match "system.*") &&
48
+ !(_type match "sanity.*")
49
+ ]
50
+ ````
51
+
20
52
  ## Configuration
21
53
 
22
- Edit `./config/graph-view.json`:
54
+ You can control which documents appear in the graph by providing a query:
55
+
56
+ ```js
57
+ import { contentGraphView } from "sanity-plugin-graph-view";
23
58
 
24
- ```json
25
- {
26
- "query": "*[_type == 'a' || _type == 'b']"
27
- }
59
+ export default createConfig({
60
+ // ...
61
+ plugins: [
62
+ contentGraphView({
63
+ "query": "*[_type in ['a', 'b']]"
64
+ }),
65
+ ]
66
+ })
28
67
  ```
29
68
 
30
- For references to turn into graph edges, the entire document must be fetched, but you can also selectively filter what references will be included. For example:
69
+ For references to turn into graph edges, the entire document must be fetched,
70
+ but you can also selectively filter what references will be included. For example:
31
71
 
32
- ```json
33
- {
34
- "query": "*[_type == 'a' || _type == 'b']{ 'refs': [author._ref, publisher._ref] }"
35
- }
72
+ ```js
73
+ contentGraphView({
74
+ "query": "*[_type in ['a', 'b']]{ 'refs': [author, publisher] }"
75
+ })
36
76
  ```
37
77
 
38
- ## Contributing
78
+ By default, the plugin uses `doc.title || doc.name || doc._id` as the node label.
39
79
 
40
- If you want to take part in developing this plugin, then look for planned features in the [list of issues](https://github.com/sanity-io/sanity-plugin-graph-view/issues) and reach out to us in the [Sanity Community](https://slack.sanity.io/).
80
+ If you want to use another property, compute a `title` property in your query, e.g.:
41
81
 
42
- ```sh
43
- git clone git@github.com:sanity-io/sanity-plugin-graph-view.git
44
- cd sanity-plugin-graph-view
45
- yarn
46
- yarn link
47
82
 
48
- # In a development Studio directory:
49
- yarn link sanity-plugin-graph-view
50
-
51
- # Lint your code before committing
52
- yarn lint
83
+ ```js
84
+ contentGraphView({
85
+ "query": "*[_type in ['a', 'b']] { ..., \"title\": select(_type == 'a' => 'Title A', _type == 'b' => 'Title B') }"
86
+ })
53
87
  ```
54
88
 
55
89
  ## Get help in the Sanity Community
@@ -61,3 +95,25 @@ Join [Sanity’s developer community](https://slack.sanity.io) or ping us [on tw
61
95
  ## License
62
96
 
63
97
  MIT © [Sanity.io](https://www.sanity.io/)
98
+
99
+ ## Develop & test
100
+
101
+ Make sure to run `npm run build` once, then run
102
+
103
+ ```bash
104
+ npm run link-watch
105
+ ```
106
+
107
+ In another shell, `cd` to your test studio and run:
108
+
109
+ ```bash
110
+ npx yalc add @sanity/sanity-plugin-graph-view && yarn install
111
+ ```
112
+
113
+ Now, changes in this repo will be automatically built and pushed to the studio,
114
+ triggering hotreload. Yalc avoids issues with react-hooks that are typical when using yarn/npm link.
115
+
116
+ ### About build & watch
117
+
118
+ This plugin uses [@sanity/plugin-sdk](https://github.com/sanity-io/plugin-sdk)
119
+ with default configuration for build & watch scripts.
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ interface GraphViewConfig {
2
+ query?: string;
3
+ }
4
+ export const contentGraphView: import("sanity").Plugin<GraphViewConfig>;
5
+
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"mappings":"AKMA;IACE,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,OAAO,MAAM,0DAmBX,CAAA","sources":["src/src/tool/hooks.ts","src/src/tool/utils.ts","src/src/tool/GraphViewStyle.tsx","src/src/tool/GraphView.tsx","src/src/tool/GraphViewIcon.tsx","src/src/index.tsx","src/index.tsx"],"sourcesContent":[null,null,null,null,null,null,"import {GraphView} from './tool/GraphView'\nimport {GraphViewIcon} from './tool/GraphViewIcon'\nimport {createPlugin} from 'sanity'\nimport {route} from 'sanity/_unstable'\nimport React from 'react'\n\ninterface GraphViewConfig {\n query?: string\n}\n\nexport const contentGraphView = createPlugin<GraphViewConfig>((config: GraphViewConfig = {}) => {\n return {\n name: '@sanity/content-graph-view',\n\n tools: (prev) => {\n return [\n ...prev,\n {\n name: 'graph-your-content',\n title: 'Graph',\n icon: GraphViewIcon,\n component: function component() {\n return <GraphView {...config} />\n },\n router: route.create('/:selectedDocumentId'),\n },\n ]\n },\n }\n})\n"],"names":[],"version":3,"file":"index.d.ts.map","sourceRoot":"../"}