From 40bd51313804fea447414d527be98e08798b98c2 Mon Sep 17 00:00:00 2001 From: Amaan Khan Date: Thu, 30 Jan 2025 21:44:49 +0530 Subject: [PATCH 1/8] feat: adds docs for mudating default data --- docs/mutating-data.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 docs/mutating-data.md diff --git a/docs/mutating-data.md b/docs/mutating-data.md new file mode 100644 index 00000000..afa08bae --- /dev/null +++ b/docs/mutating-data.md @@ -0,0 +1,31 @@ +# Global Styles + +Global styles can be mutated by passing `getGlobalStyles` attribute to `RootLayout` in `src/app/layout.tsx`. + +`getGlobalStyles` takes an async callback function that returns an object containing global styles. + +The default definition for `getGlobalStyles` function passed in `getGlobalStyles` attribute to `RootLayout` in `src/app/[[...path]]/layout.tsx`, can be found in [@snapwp/query](../packages/next/README.md) package. + +Type Definition of `getGlobalStyles`: + +```typescript +() => Promise< GlobalHeadProps > +``` + +Type definition of `GlobalHeadProps` can be found in [@snapwp/core](../packages/next/README.md) package. + +# Template Data + +Template data can be mutated by passing `getTemplateData` attribute to `TemplateRenderer` in `src/app/[[...path]]/page.tsx`. + +`getTemplateData` takes an async callback to get template styles and content. + +The default definition for `getTemplateData` function passed in `getTemplateData` attribute to `TemplateRenderer` in `src/app/[[...path]]/page.tsx`, can be found in [@snapwp/query](../packages/next/README.md) package. + +Type Definition of `getTemplateData`: + +```typescript +( uri: string ) => Promise< TemplateData > +``` + +Type definition of `TemplateData` can be found in [@snapwp/core](../packages/next/README.md) package. From 6d69606016a489779e737fa41cdf9b402bd2880e Mon Sep 17 00:00:00 2001 From: Amaan Khan Date: Thu, 30 Jan 2025 21:47:04 +0530 Subject: [PATCH 2/8] refactor: updates file namec --- docs/{mutating-data.md => mutating-query.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/{mutating-data.md => mutating-query.md} (100%) diff --git a/docs/mutating-data.md b/docs/mutating-query.md similarity index 100% rename from docs/mutating-data.md rename to docs/mutating-query.md From 9c22e5043e777c606e0cb4801c2adfbb7f90afd8 Mon Sep 17 00:00:00 2001 From: Amaan Khan Date: Thu, 30 Jan 2025 21:56:36 +0530 Subject: [PATCH 3/8] refactor: updates type definations in mutating-query doc --- docs/mutating-query.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/mutating-query.md b/docs/mutating-query.md index afa08bae..fd475425 100644 --- a/docs/mutating-query.md +++ b/docs/mutating-query.md @@ -9,7 +9,7 @@ The default definition for `getGlobalStyles` function passed in `getGlobalStyles Type Definition of `getGlobalStyles`: ```typescript -() => Promise< GlobalHeadProps > +type getGlobalStyles = () => Promise< GlobalHeadProps >; ``` Type definition of `GlobalHeadProps` can be found in [@snapwp/core](../packages/next/README.md) package. @@ -25,7 +25,7 @@ The default definition for `getTemplateData` function passed in `getTemplateData Type Definition of `getTemplateData`: ```typescript -( uri: string ) => Promise< TemplateData > +type getTemplateData = ( uri: string ) => Promise< TemplateData >; ``` Type definition of `TemplateData` can be found in [@snapwp/core](../packages/next/README.md) package. From 3221009c6d2b150967f07688462e3ca89c2a33a2 Mon Sep 17 00:00:00 2001 From: Amaan Khan Date: Thu, 6 Feb 2025 17:35:42 +0530 Subject: [PATCH 4/8] fix: package URL --- docs/mutating-query.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/mutating-query.md b/docs/mutating-query.md index fd475425..738065a6 100644 --- a/docs/mutating-query.md +++ b/docs/mutating-query.md @@ -4,7 +4,7 @@ Global styles can be mutated by passing `getGlobalStyles` attribute to `RootLayo `getGlobalStyles` takes an async callback function that returns an object containing global styles. -The default definition for `getGlobalStyles` function passed in `getGlobalStyles` attribute to `RootLayout` in `src/app/[[...path]]/layout.tsx`, can be found in [@snapwp/query](../packages/next/README.md) package. +The default definition for `getGlobalStyles` function passed in `getGlobalStyles` attribute to `RootLayout` in `src/app/[[...path]]/layout.tsx`, can be found in [@snapwp/query](../packages/query/README.md) package. Type Definition of `getGlobalStyles`: @@ -12,7 +12,7 @@ Type Definition of `getGlobalStyles`: type getGlobalStyles = () => Promise< GlobalHeadProps >; ``` -Type definition of `GlobalHeadProps` can be found in [@snapwp/core](../packages/next/README.md) package. +Type definition of `GlobalHeadProps` can be found in [@snapwp/core](../packages/core/README.md) package. # Template Data @@ -20,7 +20,7 @@ Template data can be mutated by passing `getTemplateData` attribute to `Template `getTemplateData` takes an async callback to get template styles and content. -The default definition for `getTemplateData` function passed in `getTemplateData` attribute to `TemplateRenderer` in `src/app/[[...path]]/page.tsx`, can be found in [@snapwp/query](../packages/next/README.md) package. +The default definition for `getTemplateData` function passed in `getTemplateData` attribute to `TemplateRenderer` in `src/app/[[...path]]/page.tsx`, can be found in [@snapwp/query](../packages/query/README.md) package. Type Definition of `getTemplateData`: @@ -28,4 +28,4 @@ Type Definition of `getTemplateData`: type getTemplateData = ( uri: string ) => Promise< TemplateData >; ``` -Type definition of `TemplateData` can be found in [@snapwp/core](../packages/next/README.md) package. +Type definition of `TemplateData` can be found in [@snapwp/core](../packages/core/README.md) package. From e519aeb9c6e54c9fb837b76feb165749b7d8ed90 Mon Sep 17 00:00:00 2001 From: Amaan Khan Date: Mon, 17 Feb 2025 12:47:59 +0530 Subject: [PATCH 5/8] refactor: migrate docs to next package --- docs/mutating-query.md | 31 ------------------------------- packages/next/README.md | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 31 deletions(-) delete mode 100644 docs/mutating-query.md diff --git a/docs/mutating-query.md b/docs/mutating-query.md deleted file mode 100644 index 738065a6..00000000 --- a/docs/mutating-query.md +++ /dev/null @@ -1,31 +0,0 @@ -# Global Styles - -Global styles can be mutated by passing `getGlobalStyles` attribute to `RootLayout` in `src/app/layout.tsx`. - -`getGlobalStyles` takes an async callback function that returns an object containing global styles. - -The default definition for `getGlobalStyles` function passed in `getGlobalStyles` attribute to `RootLayout` in `src/app/[[...path]]/layout.tsx`, can be found in [@snapwp/query](../packages/query/README.md) package. - -Type Definition of `getGlobalStyles`: - -```typescript -type getGlobalStyles = () => Promise< GlobalHeadProps >; -``` - -Type definition of `GlobalHeadProps` can be found in [@snapwp/core](../packages/core/README.md) package. - -# Template Data - -Template data can be mutated by passing `getTemplateData` attribute to `TemplateRenderer` in `src/app/[[...path]]/page.tsx`. - -`getTemplateData` takes an async callback to get template styles and content. - -The default definition for `getTemplateData` function passed in `getTemplateData` attribute to `TemplateRenderer` in `src/app/[[...path]]/page.tsx`, can be found in [@snapwp/query](../packages/query/README.md) package. - -Type Definition of `getTemplateData`: - -```typescript -type getTemplateData = ( uri: string ) => Promise< TemplateData >; -``` - -Type definition of `TemplateData` can be found in [@snapwp/core](../packages/core/README.md) package. diff --git a/packages/next/README.md b/packages/next/README.md index d1533dcc..5c38469c 100644 --- a/packages/next/README.md +++ b/packages/next/README.md @@ -207,6 +207,39 @@ export default function CustomFonts() { } ``` +### Updating Global Styles + +Global styles can be modified by passing the `getGlobalStyles` attribute to the `RootLayout` within the `src/app/layout.tsx` file of the frontend application. + +`getGlobalStyles` takes an async callback function that returns an object containing global styles. + +The default definition for `getGlobalStyles` function passed in `getGlobalStyles` attribute can be found in [@snapwp/query](../packages/query/README.md) package. + +Type Definition of `getGlobalStyles`: + +```typescript +type getGlobalStyles = () => Promise< GlobalHeadProps >; +``` + +Type definition of `GlobalHeadProps` can be found in [@snapwp/core](../packages/core/README.md) package. + +### Updating Template Data + +Template data can be modified by passing `getTemplateData` attribute to the `TemplateRenderer` within `src/app/[[...path]]/page.tsx` file of the frontend application. + +`getTemplateData` takes an async callback to get template styles and content. + +The default definition for `getTemplateData` function passed in `getTemplateData` attribute can be found in [@snapwp/query](../packages/query/README.md) package. + +Type Definition of `getTemplateData`: + +```typescript +type getTemplateData = ( uri: string ) => Promise< TemplateData >; +``` + +Type definition of `TemplateData` can be found in [@snapwp/core](../packages/core/README.md) package. + + ## Contributing This package is part of [SnapWP's monorepo](https://github.com/rtCamp/snapwp) and is actively maintained by [rtCamp](https://rtcamp.com/). Packages are published to [npm](https://www.npmjs.com/) from the `packages` directory, and can be used standalone in the headless WordPress ecosystem or as part of SnapWP's framework. From d757a1c08912eec86a14c13414e78fbba5d48197 Mon Sep 17 00:00:00 2001 From: Amaan Khan Date: Mon, 17 Feb 2025 12:50:27 +0530 Subject: [PATCH 6/8] refactor: format next readme --- packages/next/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/next/README.md b/packages/next/README.md index 5c38469c..5e460593 100644 --- a/packages/next/README.md +++ b/packages/next/README.md @@ -239,7 +239,6 @@ type getTemplateData = ( uri: string ) => Promise< TemplateData >; Type definition of `TemplateData` can be found in [@snapwp/core](../packages/core/README.md) package. - ## Contributing This package is part of [SnapWP's monorepo](https://github.com/rtCamp/snapwp) and is actively maintained by [rtCamp](https://rtcamp.com/). Packages are published to [npm](https://www.npmjs.com/) from the `packages` directory, and can be used standalone in the headless WordPress ecosystem or as part of SnapWP's framework. From 40fb8888dfc713180352e273368187d15a7d58b3 Mon Sep 17 00:00:00 2001 From: Amaan Khan Date: Mon, 17 Feb 2025 13:19:03 +0530 Subject: [PATCH 7/8] refactor: add link to component in next package readme --- packages/next/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/next/README.md b/packages/next/README.md index 5e460593..8b7b0e70 100644 --- a/packages/next/README.md +++ b/packages/next/README.md @@ -209,7 +209,7 @@ export default function CustomFonts() { ### Updating Global Styles -Global styles can be modified by passing the `getGlobalStyles` attribute to the `RootLayout` within the `src/app/layout.tsx` file of the frontend application. +Global styles can be modified by passing the `getGlobalStyles` attribute to the [RootLayout](./src/root-layout/index.tsx) within the `src/app/layout.tsx` file of the frontend application. `getGlobalStyles` takes an async callback function that returns an object containing global styles. @@ -225,7 +225,7 @@ Type definition of `GlobalHeadProps` can be found in [@snapwp/core](../packages/ ### Updating Template Data -Template data can be modified by passing `getTemplateData` attribute to the `TemplateRenderer` within `src/app/[[...path]]/page.tsx` file of the frontend application. +Template data can be modified by passing `getTemplateData` attribute to the [TemplateRenderer](./src/template-renderer/index.tsx) within `src/app/[[...path]]/page.tsx` file of the frontend application. `getTemplateData` takes an async callback to get template styles and content. From 4054f59b87994129e413e8f7d2d707eb0c2d0d32 Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Tue, 18 Feb 2025 01:56:56 +0200 Subject: [PATCH 8/8] chore: cleanup --- docs/getting-started.md | 2 +- packages/next/README.md | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 34c2e071..f2cc32e4 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -7,7 +7,7 @@ This guide will walk you through setting up a headless WordPress app using SnapW ### Prerequisites - **PHP**: v7.4+ -- **WordPress**: v6.0+ +- **WordPress**: v6.7+ - A **[Block Theme](https://wordpress.org/documentation/article/block-themes/)** ### Installation Steps diff --git a/packages/next/README.md b/packages/next/README.md index 8b7b0e70..8ed91a90 100644 --- a/packages/next/README.md +++ b/packages/next/README.md @@ -167,16 +167,16 @@ export default function ScriptModuleExample() { + dependencies={[ + { + importType: 'static', + connectedScriptModule: { + handle: '@module', + src: 'http://example.com/index.min.js' + } + } + ]} + /> ); } @@ -207,7 +207,7 @@ export default function CustomFonts() { } ``` -### Updating Global Styles +### `getGlobalStyles()` Global styles can be modified by passing the `getGlobalStyles` attribute to the [RootLayout](./src/root-layout/index.tsx) within the `src/app/layout.tsx` file of the frontend application. @@ -223,7 +223,7 @@ type getGlobalStyles = () => Promise< GlobalHeadProps >; Type definition of `GlobalHeadProps` can be found in [@snapwp/core](../packages/core/README.md) package. -### Updating Template Data +### `getTemplateData()` Template data can be modified by passing `getTemplateData` attribute to the [TemplateRenderer](./src/template-renderer/index.tsx) within `src/app/[[...path]]/page.tsx` file of the frontend application.