drupal-decoupled 0.1.0 → 0.2.0

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,61 +1,22 @@
1
- # Drupal-Decoupled
2
-
3
- A list of utilities for a Decoupled integrations
4
-
5
- ### Route Syncronization and comunication between FE and BE via the Iframe
6
-
7
- Import the `syncDrupalPreviewRoutes` helper at `app/root.tsx`
8
-
9
- ```typescript
10
- import { syncDrupalPreviewRoutes } from "drupal-remix";
11
- ```
12
-
13
- Make sure your loader returns the current `environment` value
14
-
15
- ```typescript
16
- export const loader = async ({ context }: LoaderFunctionArgs ) => {
17
- // Provide a variable to define the environment
18
- const environment = context.cloudflare.env.ENVIRONMENT
19
- return json(
20
- {
21
- environment,
22
- },
23
- { status: 200 }
24
- );
25
- };
26
- ```
27
-
28
- > NOTE: This example is using Cloudflare and taking advantage of Environemt Settings to define "environment" key/value, that is why we are using the `context.cloudflare.env.ENVIRONMENT` object to obtain the value and pass it from Server to Client.
29
-
30
- Upate your `App` function
31
-
32
- ```typescript
33
- export default function App() {
34
- // read environment from loader
35
- const { environment } = useLoaderData<typeof loader>();
36
- // use the useNavigation hook from @remix-run/react
37
- const navigation = useNavigation();
38
-
39
- // check if environment is preview and navigation.state is loading
40
- // to call syncDrupalPreviewRoutes
41
- if (environment === "preview" && navigation.state === "loading") {
42
- syncDrupalPreviewRoutes(navigation.location.pathname);
43
- }
44
-
45
- return (
46
- <>
47
- <Outlet />
48
- </>
49
- );
50
- }
51
- ```
52
-
53
- For a fully functional example visit any of those repositories:
54
- - GraphQL:
55
- - [Remix](https://github.com/octahedroid/drupal-remix/tree/main/examples/graphql)
56
- - [Drupal]()
57
-
58
- - JSON:API (TBD)
1
+ # Build Drupal Decoupled Sites Faster & Smarter
2
+
3
+ Using Drupal as a headless CMS with a Decoupled front-end implementation is a great way to get an enterprise-quality CMS, paired with a great modern development experience using Remix, Next.js, Astro and/or others.
4
+
5
+ Unlock the full potential of Drupal as an API-first CMS. Our quick-start guides and ready-to-use examples help you get started in no time!
6
+
7
+ ## Explore Drupal Decoupled
8
+
9
+ Visit the [docs](https://drupal-decoupled.octahedroid.com/) to see how to use this project.
10
+
11
+ ### Quickstart
12
+ - [Drupal](https://drupal-decoupled.octahedroid.com/docs/getting-started/quickstart/drupal)
13
+ - [Remix](https://drupal-decoupled.octahedroid.com/docs/getting-started/quickstart/remix)
14
+ - [Next.js](https://drupal-decoupled.octahedroid.com/docs/getting-started/quickstart/next)
15
+
16
+ ### Step by step
17
+ - [Drupal](https://drupal-decoupled.octahedroid.com/docs/getting-started/step-by-step/drupal)
18
+ - [Remix](https://drupal-decoupled.octahedroid.com/docs/getting-started/step-by-step/starters/remix)
19
+ - [Next.js](https://drupal-decoupled.octahedroid.com/docs/getting-started/step-by-step/starters/next)
59
20
 
60
21
  ## Supporting organizations
61
22
 
@@ -0,0 +1 @@
1
+ export * from "./seo";
@@ -0,0 +1 @@
1
+ var l=[{charSet:"utf-8"},{name:"viewport",content:"width=device-width,initial-scale=1"}],c=(e,o)=>typeof e=="string"?e:(Array.isArray(e)||(e=[e]),e.reduce((g,{pattern:s,replacement:p})=>g?.replace(s,p),o)),T=({tags:e,defaultTags:o=[],metaTagOverrides:g})=>{let s=e.find(t=>t.__typename==="MetaTagValue"&&t.attributes.name==="title"),p=e.map(t=>{let u=g?.[t.__typename];if(t.__typename==="MetaTagLink"){let{rel:n,href:a}=t.attributes,r=u?.[n];if(!r)return{tagName:"link",rel:n,href:a};let i=c(r,a);return{tagName:"link",rel:n,href:i}}if(t.__typename==="MetaTagProperty"){let{property:n,content:a}=t.attributes,r=u?.[n];if(!r)return{property:t.attributes.property,content:t.attributes.content};let i=c(r,a);return{property:n,content:i}}if(t.__typename==="MetaTagValue"){let{name:n,content:a}=t.attributes,r=u?.[n];if(!r)return{name:t.attributes.name,content:t.attributes.content};let i=c(r,a);return{name:n,content:i}}});return[...l,...o,s?{title:s.attributes.content}:{},...p]};export{T as metaTags};
@@ -0,0 +1,66 @@
1
+ type MetaDescriptor = {
2
+ charSet: "utf-8";
3
+ } | {
4
+ title: string;
5
+ } | {
6
+ name: string;
7
+ content: string;
8
+ } | {
9
+ property: string;
10
+ content: string;
11
+ } | {
12
+ httpEquiv: string;
13
+ content: string;
14
+ } | {
15
+ [name: string]: string;
16
+ tagName: "meta" | "link";
17
+ } | {
18
+ [name: string]: unknown;
19
+ };
20
+ type MetaTagUnion = (MetaTagLink | MetaTagValue | MetaTagProperty) & {
21
+ __isUnion?: true;
22
+ };
23
+ interface MetaTagLink {
24
+ attributes: MetaTagLinkAttributes;
25
+ __typename: "MetaTagLink";
26
+ }
27
+ export type MetaTag = MetaTagLink | MetaTagValue | MetaTagProperty;
28
+ interface MetaTagLinkAttributes {
29
+ rel?: string | null;
30
+ href?: string | null;
31
+ }
32
+ interface MetaTagValue {
33
+ attributes: MetaTagValueAttributes;
34
+ __typename: "MetaTagValue";
35
+ }
36
+ interface MetaTagValueAttributes {
37
+ name?: string | null;
38
+ content?: string | null;
39
+ }
40
+ interface MetaTagProperty {
41
+ attributes: MetaTagPropertyAttributes;
42
+ __typename: "MetaTagProperty";
43
+ }
44
+ interface MetaTagPropertyAttributes {
45
+ property?: string | null;
46
+ content?: string | null;
47
+ }
48
+ type OverrideOptionsReplace = {
49
+ kind: string;
50
+ pattern: string;
51
+ replacement: string;
52
+ }[];
53
+ type OverrideOptions = string | OverrideOptionsReplace;
54
+ type MetaTagOverrides = {
55
+ [key in MetaTagUnion["__typename"]]?: {
56
+ [key: string]: OverrideOptions;
57
+ };
58
+ };
59
+ export declare const metaTags: ({ tags, defaultTags, metaTagOverrides, }: {
60
+ tags: MetaTag[];
61
+ defaultTags?: {
62
+ [key: string]: string | undefined;
63
+ }[] | undefined;
64
+ metaTagOverrides?: MetaTagOverrides | undefined;
65
+ }) => Array<MetaDescriptor>;
66
+ export {};
@@ -0,0 +1 @@
1
+ var l=[{charSet:"utf-8"},{name:"viewport",content:"width=device-width,initial-scale=1"}],c=(e,o)=>typeof e=="string"?e:(Array.isArray(e)||(e=[e]),e.reduce((g,{pattern:s,replacement:p})=>g?.replace(s,p),o)),T=({tags:e,defaultTags:o=[],metaTagOverrides:g})=>{let s=e.find(t=>t.__typename==="MetaTagValue"&&t.attributes.name==="title"),p=e.map(t=>{let u=g?.[t.__typename];if(t.__typename==="MetaTagLink"){let{rel:n,href:a}=t.attributes,r=u?.[n];if(!r)return{tagName:"link",rel:n,href:a};let i=c(r,a);return{tagName:"link",rel:n,href:i}}if(t.__typename==="MetaTagProperty"){let{property:n,content:a}=t.attributes,r=u?.[n];if(!r)return{property:t.attributes.property,content:t.attributes.content};let i=c(r,a);return{property:n,content:i}}if(t.__typename==="MetaTagValue"){let{name:n,content:a}=t.attributes,r=u?.[n];if(!r)return{name:t.attributes.name,content:t.attributes.content};let i=c(r,a);return{name:n,content:i}}});return[...l,...o,s?{title:s.attributes.content}:{},...p]};export{T as metaTags};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drupal-decoupled",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Drupal utils for Decoupled integrations",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -27,14 +27,27 @@
27
27
  },
28
28
  "author": "Octahedroid <opensource@octahedroid.com>",
29
29
  "repository": {
30
- "url": "https://github.com/octahedroid/drupal-decoupled/tree/main/packages/drupal-decoupled"
30
+ "url": "git+https://github.com/octahedroid/drupal-decoupled.git#main"
31
+ },
32
+ "exports": {
33
+ ".": "./dist/index.js",
34
+ "./remix": "./dist/remix/index.js"
31
35
  },
32
36
  "license": "MIT",
37
+ "dependencies": {
38
+ "@measured/puck": "^0.18.1",
39
+ "immutable-json-patch": "^6.0.1",
40
+ "jmespath": "^0.16.0",
41
+ "react": "^18.2.0",
42
+ "react-dom": "^18.2.0"
43
+ },
33
44
  "devDependencies": {
45
+ "@types/jmespath": "^0.15.2",
34
46
  "@types/node": "^18.11.3",
47
+ "@types/react": "^18.2.20",
48
+ "@types/react-dom": "^18.2.7",
35
49
  "esbuild": "^0.17.18",
36
50
  "rimraf": "^5.0.0",
37
51
  "typescript": "^4.8.4"
38
- },
39
- "dependencies": {}
52
+ }
40
53
  }