diff --git a/.changeset/blue-hairs-warn.md b/.changeset/blue-hairs-warn.md new file mode 100644 index 000000000..05d664869 --- /dev/null +++ b/.changeset/blue-hairs-warn.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/next": patch +--- + +[Pages Router] Add support for `wyw-in-js` and latest version of linaria diff --git a/.changeset/bright-glasses-press.md b/.changeset/bright-glasses-press.md new file mode 100644 index 000000000..6098a10b4 --- /dev/null +++ b/.changeset/bright-glasses-press.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/next": patch +--- + +Fix: windows support diff --git a/.changeset/chilled-pants-suffer.md b/.changeset/chilled-pants-suffer.md new file mode 100644 index 000000000..e6cf50bd8 --- /dev/null +++ b/.changeset/chilled-pants-suffer.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": patch +"@headstartwp/next": patch +--- + +Fix fetch settings for next.js diff --git a/.changeset/config.json b/.changeset/config.json index bbf76cb30..cbf5d706a 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -8,5 +8,17 @@ "baseBranch": "trunk", "updateInternalDependencies": "patch", "privatePackages": { "version": true, "tag": false }, - "ignore": ["@10up/wp-nextjs", "@10up/wp-multisite-nextjs", "@10up/wp-multisite-i18n-nextjs"] + "ignore": [ + "@10up/wp-nextjs", + "@10up/wp-nextjs-app", + "@10up/wp-nextjs-epio", + "@10up/wp-polylang-nextjs-app", + "@10up/wp-multisite-nextjs-app", + "@10up/wp-multisite-nextjs", + "@10up/wp-multisite-i18n-nextjs", + "@headstartwp/vite-react-test", + "@10up/wp-nextjs-universal-blocks", + "@headstartwp/component-library", + "tenup-theme" + ] } \ No newline at end of file diff --git a/.changeset/cute-shoes-dance.md b/.changeset/cute-shoes-dance.md new file mode 100644 index 000000000..85b86b99c --- /dev/null +++ b/.changeset/cute-shoes-dance.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/next": patch +--- + +Fix: revalidate path +Added: A new optional callback parameter was added to `revalidateRouteHandler`. This callback allows extra logic to be run after the path is revalidated. For instance, `revalidateTag` may need to be called for a specific query, or a redis tag may need to be deleted. diff --git a/.changeset/cyan-fans-clean.md b/.changeset/cyan-fans-clean.md new file mode 100644 index 000000000..c156be2a2 --- /dev/null +++ b/.changeset/cyan-fans-clean.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": minor +"@headstartwp/next": minor +--- + +Introducing previewRouteHandler to handle preview in Next.js App Router diff --git a/.changeset/dry-lamps-approve.md b/.changeset/dry-lamps-approve.md new file mode 100644 index 000000000..474c39e73 --- /dev/null +++ b/.changeset/dry-lamps-approve.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/epio-search": patch +--- + +correctly export types diff --git a/.changeset/famous-apples-knock.md b/.changeset/famous-apples-knock.md new file mode 100644 index 000000000..c2cc98e9f --- /dev/null +++ b/.changeset/famous-apples-knock.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": patch +"@headstartwp/next": patch +--- + +Allow overriding fetch strategy diff --git a/.changeset/forty-apes-repair.md b/.changeset/forty-apes-repair.md new file mode 100644 index 000000000..3cedcc0f2 --- /dev/null +++ b/.changeset/forty-apes-repair.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": minor +"@headstartwp/next": minor +--- + +Initial App Router Support diff --git a/.changeset/forty-planets-fix.md b/.changeset/forty-planets-fix.md new file mode 100644 index 000000000..cb27348d8 --- /dev/null +++ b/.changeset/forty-planets-fix.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": patch +"@headstartwp/next": patch +--- + +Fix: return config from queryPostOrPosts diff --git a/.changeset/free-rocks-take.md b/.changeset/free-rocks-take.md new file mode 100644 index 000000000..dc7118d62 --- /dev/null +++ b/.changeset/free-rocks-take.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/core": patch +--- + +Fix: account for possible `single` property in the default post types when executing the default post path matching. diff --git a/.changeset/funny-poems-own.md b/.changeset/funny-poems-own.md new file mode 100644 index 000000000..3ed82effe --- /dev/null +++ b/.changeset/funny-poems-own.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": minor +"@headstartwp/next": minor +--- + +Introducing SEO handling for App Router diff --git a/.changeset/fuzzy-cows-press.md b/.changeset/fuzzy-cows-press.md new file mode 100644 index 000000000..d295e92a0 --- /dev/null +++ b/.changeset/fuzzy-cows-press.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": minor +"@headstartwp/next": minor +--- + +Link handling diff --git a/.changeset/happy-bugs-obey.md b/.changeset/happy-bugs-obey.md new file mode 100644 index 000000000..b74b789c0 --- /dev/null +++ b/.changeset/happy-bugs-obey.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/next": patch +--- + +Opt into image.remotePatters for Next.js versions that supports it diff --git a/.changeset/happy-squids-admire.md b/.changeset/happy-squids-admire.md new file mode 100644 index 000000000..c2447593e --- /dev/null +++ b/.changeset/happy-squids-admire.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": minor +"@headstartwp/next": minor +--- + +Adding support for `i18n` routing in app router diff --git a/.changeset/heavy-bikes-join.md b/.changeset/heavy-bikes-join.md new file mode 100644 index 000000000..016f4800e --- /dev/null +++ b/.changeset/heavy-bikes-join.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/core": patch +--- + +Fix: only run parseBlockAttribute when forwardBlockAttribute is set for nodes that represent wp blocks diff --git a/.changeset/hot-cycles-raise.md b/.changeset/hot-cycles-raise.md new file mode 100644 index 000000000..6ccb0ba45 --- /dev/null +++ b/.changeset/hot-cycles-raise.md @@ -0,0 +1,7 @@ +--- +"@headstartwp/headstartwp": minor +"@headstartwp/core": minor +"@headstartwp/next": minor +--- + +Feature: Introducing the ability to load block library styles and dynamic inline styles generated by the block editor diff --git a/.changeset/hungry-mangos-repeat.md b/.changeset/hungry-mangos-repeat.md new file mode 100644 index 000000000..fb69e10e2 --- /dev/null +++ b/.changeset/hungry-mangos-repeat.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/core": minor +--- + +Fix: xss import issue diff --git a/.changeset/itchy-cooks-tap.md b/.changeset/itchy-cooks-tap.md new file mode 100644 index 000000000..0d8b5736f --- /dev/null +++ b/.changeset/itchy-cooks-tap.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/next": patch +--- + +Fixed - Fixed isValidLocale function to validate against the configuration +Added - New test condition for technically valid, but unsupported locale \ No newline at end of file diff --git a/.changeset/kind-experts-divide.md b/.changeset/kind-experts-divide.md new file mode 100644 index 000000000..3b6509877 --- /dev/null +++ b/.changeset/kind-experts-divide.md @@ -0,0 +1,9 @@ +--- +"@10up/next-redis-cache-provider": minor +"@headstartwp/block-primitives": minor +"@headstartwp/epio-search": minor +"@headstartwp/core": minor +"@headstartwp/next": minor +--- + +Add support for Next.js 15 diff --git a/.changeset/large-spies-give.md b/.changeset/large-spies-give.md new file mode 100644 index 000000000..09d90ae72 --- /dev/null +++ b/.changeset/large-spies-give.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": patch +"@headstartwp/next": patch +--- + +remove usage of defaultProps and intropduce the ability to attach a default test function directly to the component diff --git a/.changeset/late-rings-design.md b/.changeset/late-rings-design.md new file mode 100644 index 000000000..9d8f6a413 --- /dev/null +++ b/.changeset/late-rings-design.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": patch +"@headstartwp/headstartwp": patch +--- + +Fix: do not cast menu item ids to number as they are strings diff --git a/.changeset/many-drinks-prove.md b/.changeset/many-drinks-prove.md new file mode 100644 index 000000000..c80dc04fa --- /dev/null +++ b/.changeset/many-drinks-prove.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/headstartwp": minor +--- + +feat: ensure all internal images added to the block editor contains width and height. diff --git a/.changeset/modern-crabs-run.md b/.changeset/modern-crabs-run.md new file mode 100644 index 000000000..5cf4e8855 --- /dev/null +++ b/.changeset/modern-crabs-run.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/epio-search": major +--- + +Introducing `@headstartwp/epio-search` diff --git a/.changeset/moody-emus-matter.md b/.changeset/moody-emus-matter.md new file mode 100644 index 000000000..dd41a9f3f --- /dev/null +++ b/.changeset/moody-emus-matter.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": minor +"@headstartwp/next": minor +--- + +Introducing `revalidateRouteHandler` for handling revalidate requests in Route Handlers (App Router) diff --git a/.changeset/orange-shirts-relax.md b/.changeset/orange-shirts-relax.md new file mode 100644 index 000000000..081f48d2f --- /dev/null +++ b/.changeset/orange-shirts-relax.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/next": patch +--- + +Ensure query string is appended to URL rewrite/redirect in middleware diff --git a/.changeset/perfect-cobras-knock.md b/.changeset/perfect-cobras-knock.md new file mode 100644 index 000000000..a0a2f9724 --- /dev/null +++ b/.changeset/perfect-cobras-knock.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": minor +"@headstartwp/next": minor +--- + +Add the ability to add aliases/slug to sites in the multisite setup diff --git a/.changeset/perfect-pumas-approve.md b/.changeset/perfect-pumas-approve.md new file mode 100644 index 000000000..c95dc893f --- /dev/null +++ b/.changeset/perfect-pumas-approve.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/core": patch +--- + +Fix TS type for link component in SettingsContextProps diff --git a/.changeset/poor-donkeys-march.md b/.changeset/poor-donkeys-march.md new file mode 100644 index 000000000..29e731eb8 --- /dev/null +++ b/.changeset/poor-donkeys-march.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": minor +"@headstartwp/next": minor +--- + +RSC compatible image block for next.js diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 000000000..be4d2770d --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,67 @@ +{ + "mode": "pre", + "tag": "next", + "initialVersions": { + "@headstartwp/core": "1.4.4", + "@headstartwp/next": "1.4.3", + "@10up/next-redis-cache-provider": "1.0.0", + "@10up/wp-multisite-i18n-nextjs": "0.2.0", + "@10up/wp-multisite-nextjs": "0.2.0", + "@10up/wp-multisite-nextjs-app": "0.1.0", + "@10up/wp-nextjs": "0.2.0", + "@10up/wp-nextjs-app": "0.1.0", + "@10up/wp-polylang-nextjs-app": "0.1.0", + "@headstartwp/headstartwp": "1.1.3", + "@headstartwp/vite-react-test": "0.0.0", + "@headstartwp/block-primitives": "0.0.1", + "@headstartwp/epio-search": "1.0.0-next.1", + "@headstartwp/component-library": "0.1.0", + "@10up/wp-nextjs-epio": "0.1.0", + "@10up/wp-nextjs-universal-blocks": "0.1.0", + "tenup-theme": "1.0.0" + }, + "changesets": [ + "blue-hairs-warn", + "bright-glasses-press", + "chilled-pants-suffer", + "cute-shoes-dance", + "cyan-fans-clean", + "dry-lamps-approve", + "famous-apples-knock", + "forty-apes-repair", + "forty-planets-fix", + "free-rocks-take", + "funny-poems-own", + "fuzzy-cows-press", + "happy-bugs-obey", + "happy-squids-admire", + "heavy-bikes-join", + "hot-cycles-raise", + "hungry-mangos-repeat", + "itchy-cooks-tap", + "kind-experts-divide", + "large-spies-give", + "late-rings-design", + "many-drinks-prove", + "modern-crabs-run", + "moody-emus-matter", + "orange-shirts-relax", + "perfect-cobras-knock", + "perfect-pumas-approve", + "poor-donkeys-march", + "real-places-sin", + "shiny-onions-camp", + "short-jokes-repair", + "silent-weeks-exist", + "stale-dots-remain", + "strong-scissors-shout", + "tall-moles-accept", + "tall-peas-compete", + "tasty-waves-juggle", + "two-weeks-applaud", + "warm-fireants-remain", + "whole-dingos-love", + "wild-toys-refuse", + "young-planes-jog" + ] +} diff --git a/.changeset/real-places-sin.md b/.changeset/real-places-sin.md new file mode 100644 index 000000000..73e20d36b --- /dev/null +++ b/.changeset/real-places-sin.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/next": patch +--- + +Fix type on prepareSeoMetadata diff --git a/.changeset/shiny-onions-camp.md b/.changeset/shiny-onions-camp.md new file mode 100644 index 000000000..4e4ef59ac --- /dev/null +++ b/.changeset/shiny-onions-camp.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": patch +--- + +Added - Support for custom menu item CSS classes. +Added - `menu-item-has-children` CSS class for menu item with children. \ No newline at end of file diff --git a/.changeset/short-jokes-repair.md b/.changeset/short-jokes-repair.md new file mode 100644 index 000000000..a143f8413 --- /dev/null +++ b/.changeset/short-jokes-repair.md @@ -0,0 +1,5 @@ +--- +"@10up/next-redis-cache-provider": major +--- + +Introducing support for App Router diff --git a/.changeset/silent-weeks-exist.md b/.changeset/silent-weeks-exist.md new file mode 100644 index 000000000..6e3f0b7fd --- /dev/null +++ b/.changeset/silent-weeks-exist.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/core": patch +--- + +Fix: blockGap in useBlockSetting diff --git a/.changeset/stale-dots-remain.md b/.changeset/stale-dots-remain.md new file mode 100644 index 000000000..02a653a3a --- /dev/null +++ b/.changeset/stale-dots-remain.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/block-primitives": patch +"@headstartwp/core": patch +--- + +Introducing blocks-primitives package and minor patch to core package diff --git a/.changeset/strong-scissors-shout.md b/.changeset/strong-scissors-shout.md new file mode 100644 index 000000000..e6ae677c0 --- /dev/null +++ b/.changeset/strong-scissors-shout.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/next": patch +--- + +Fix: #861 wrapper removing custom images remotePatterns diff --git a/.changeset/tall-moles-accept.md b/.changeset/tall-moles-accept.md new file mode 100644 index 000000000..2b35556d0 --- /dev/null +++ b/.changeset/tall-moles-accept.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": minor +"@headstartwp/next": minor +--- + +Add `forwardBlockProps` to BlocksRenderer which automatically forwards block props to children components diff --git a/.changeset/tall-peas-compete.md b/.changeset/tall-peas-compete.md new file mode 100644 index 000000000..7f7217bc0 --- /dev/null +++ b/.changeset/tall-peas-compete.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": patch +"@headstartwp/next": patch +--- + +Introducing `loadHeadstartWpConfig()` diff --git a/.changeset/tasty-waves-juggle.md b/.changeset/tasty-waves-juggle.md new file mode 100644 index 000000000..d9b8815d7 --- /dev/null +++ b/.changeset/tasty-waves-juggle.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": patch +"@headstartwp/next": patch +--- + +Fix fetch cache option diff --git a/.changeset/two-weeks-applaud.md b/.changeset/two-weeks-applaud.md new file mode 100644 index 000000000..f5e054094 --- /dev/null +++ b/.changeset/two-weeks-applaud.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": minor +"@headstartwp/next": minor +--- + +Introduce `blockContext` prop to BlocksRenderer and `handleError` in query functions diff --git a/.changeset/warm-fireants-remain.md b/.changeset/warm-fireants-remain.md new file mode 100644 index 000000000..4f17f1791 --- /dev/null +++ b/.changeset/warm-fireants-remain.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/next": minor +--- + +support app router in withHeadstartWPConfig diff --git a/.changeset/whole-dingos-love.md b/.changeset/whole-dingos-love.md new file mode 100644 index 000000000..23eb89756 --- /dev/null +++ b/.changeset/whole-dingos-love.md @@ -0,0 +1,5 @@ +--- +"@headstartwp/next": patch +--- + +Fix how enable() from draftMode is called diff --git a/.changeset/wild-toys-refuse.md b/.changeset/wild-toys-refuse.md new file mode 100644 index 000000000..661de2220 --- /dev/null +++ b/.changeset/wild-toys-refuse.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": minor +"@headstartwp/next": minor +--- + +Multisite support in App Router diff --git a/.changeset/young-planes-jog.md b/.changeset/young-planes-jog.md new file mode 100644 index 000000000..08e5e8a77 --- /dev/null +++ b/.changeset/young-planes-jog.md @@ -0,0 +1,6 @@ +--- +"@headstartwp/core": patch +"@headstartwp/next": patch +--- + +Fix: SEO with yoast disabled diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 000000000..8337a692e --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,49 @@ +name: Build Test + +on: [pull_request] + +jobs: + build-test: + runs-on: ${{ matrix.os }} + strategy: + # This ensures only one combination runs at a time to avoid rate limiting + max-parallel: 1 + matrix: + os: [ubuntu-latest, windows-latest] + node-version: [18, 20, 22] + exclude: + - os: windows-latest + node-version: 18 + - os: windows-latest + node-version: 20 + + steps: + - name: Configure Git line endings + if: matrix.os == 'windows-latest' + run: | + git config --global core.autocrlf false + git config --global core.eol lf + + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Node ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Setup npm cache + uses: actions/cache@v4 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Install dependencies + run: npm install + - name: Build Projects (Windows) + if: matrix.os == 'windows-latest' + run: npm run build:wpnextjs:app && npm run build:wpnextjs + - name: Build Projects + if: matrix.os != 'windows-latest' + run: npm run build \ No newline at end of file diff --git a/.github/workflows/nextjs_bundle_analysis-app-router.yml b/.github/workflows/nextjs_bundle_analysis-app-router.yml new file mode 100644 index 000000000..4bf63a9fb --- /dev/null +++ b/.github/workflows/nextjs_bundle_analysis-app-router.yml @@ -0,0 +1,113 @@ +name: '(App Router) Next.js Bundle Analysis' + +on: + pull_request: + push: + branches: + - develop # change this if your default branch is named differently + workflow_dispatch: + +defaults: + run: + # change this if your nextjs app does not live at the root of the repo + working-directory: ./projects/wp-nextjs-app + +jobs: + analyze: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up node + uses: actions/setup-node@v3 + with: + node-version: '20.x' + + - name: Install dependencies + run: (cd ../../ && npm ci) + + - name: Restore next build + uses: actions/cache@v4 + id: restore-build-cache + env: + cache-name: cache-next-build + with: + # if you use a custom build directory, replace all instances of `.next` in this file with your build directory + # ex: if your app builds to `dist`, replace `.next` with `dist` + path: .next/cache + # change this if you prefer a more strict cache + key: ${{ runner.os }}-build-${{ env.cache-name }} + + - name: Build next.js app + # change this if your site requires a custom build command + run: (cd ../../ && npm run build -- --filter=@10up/wp-nextjs-app) + + # Here's the first place where next-bundle-analysis' own script is used + # This step pulls the raw bundle stats for the current bundle + - name: Analyze bundle + run: npx -p nextjs-bundle-analysis report + + - name: Upload bundle + uses: actions/upload-artifact@v4 + with: + name: bundle + path: ./projects/wp-nextjs-app/.next/analyze/__bundle_analysis.json + + - name: Download base branch bundle stats + uses: dawidd6/action-download-artifact@v2 + if: success() && github.event.number + with: + workflow: nextjs_bundle_analysis.yml + branch: ${{ github.event.pull_request.base.ref }} + path: ./projects/wp-nextjs-app/.next/analyze/base + + # And here's the second place - this runs after we have both the current and + # base branch bundle stats, and will compare them to determine what changed. + # There are two configurable arguments that come from package.json: + # + # - budget: optional, set a budget (bytes) against which size changes are measured + # it's set to 350kb here by default, as informed by the following piece: + # https://infrequently.org/2021/03/the-performance-inequality-gap/ + # + # - red-status-percentage: sets the percent size increase where you get a red + # status indicator, defaults to 20% + # + # Either of these arguments can be changed or removed by editing the `nextBundleAnalysis` + # entry in your package.json file. + - name: Compare with base branch bundle + if: success() && github.event.number + run: ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare + + - name: Get comment body + id: get-comment-body + if: success() && github.event.number + run: | + body=$(cat .next/analyze/__bundle_analysis_comment.txt) + body="${body//'%'/'%25'}" + body="${body//$'\n'/'%0A'}" + body="${body//$'\r'/'%0D'}" + echo ::set-output name=body::$body + + - name: Find Comment + uses: peter-evans/find-comment@v1 + if: success() && github.event.number + id: fc + with: + issue-number: ${{ github.event.number }} + body-includes: '' + + - name: Create Comment + uses: peter-evans/create-or-update-comment@v1.4.4 + if: success() && github.event.number && steps.fc.outputs.comment-id == 0 + with: + issue-number: ${{ github.event.number }} + body: ${{ steps.get-comment-body.outputs.body }} + + - name: Update Comment + uses: peter-evans/create-or-update-comment@v1.4.4 + if: success() && github.event.number && steps.fc.outputs.comment-id != 0 + with: + issue-number: ${{ github.event.number }} + body: ${{ steps.get-comment-body.outputs.body }} + comment-id: ${{ steps.fc.outputs.comment-id }} + edit-mode: replace diff --git a/.github/workflows/nextjs_bundle_analysis.yml b/.github/workflows/nextjs_bundle_analysis.yml index 84fb8a489..57dc7c2af 100644 --- a/.github/workflows/nextjs_bundle_analysis.yml +++ b/.github/workflows/nextjs_bundle_analysis.yml @@ -1,4 +1,4 @@ -name: 'Next.js Bundle Analysis' +name: '(Pages Router) Next.js Bundle Analysis' on: pull_request: @@ -40,7 +40,7 @@ jobs: - name: Build next.js app # change this if your site requires a custom build command - run: npm run build + run: npm run build -- --filter=@10up/wp-nextjs # Here's the first place where next-bundle-analysis' own script is used # This step pulls the raw bundle stats for the current bundle @@ -48,7 +48,7 @@ jobs: run: npx -p nextjs-bundle-analysis report - name: Upload bundle - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: bundle path: ./projects/wp-nextjs/.next/analyze/__bundle_analysis.json diff --git a/.github/workflows/npm-release-next-version.yml b/.github/workflows/npm-release-next-version.yml index a26ef0751..f1a7a99ea 100644 --- a/.github/workflows/npm-release-next-version.yml +++ b/.github/workflows/npm-release-next-version.yml @@ -27,7 +27,7 @@ jobs: [[ ! -f .changeset/pre.json ]] && npx changeset pre enter next || echo 'already in pre mode' - name: Create Release Pull Request or Publish to npm id: changesets - uses: actions/cache@v4 + uses: changesets/action@v1 with: # This expects you to have a script called release which does a build for your packages and calls changeset publish publish: npm run publish diff --git a/.github/workflows/release-latest-version.yml b/.github/workflows/release-latest-version.yml index e928076b3..9333501d1 100644 --- a/.github/workflows/release-latest-version.yml +++ b/.github/workflows/release-latest-version.yml @@ -4,6 +4,7 @@ on: push: branches: - trunk + workflow_dispatch: concurrency: ${{ github.workflow }}-${{ github.ref }} @@ -11,6 +12,8 @@ jobs: packages: name: Release runs-on: ubuntu-latest + # Only run if on trunk branch + if: github.ref == 'refs/heads/trunk' outputs: hasChangesets: ${{ steps.changesets.outputs.hasChangesets }} steps: @@ -41,8 +44,8 @@ jobs: plugin-release: runs-on: ubuntu-latest needs: [packages] - # only run this when there are no changesets to be published - if: needs.packages.outputs.hasChangesets == 'false' + # only run this when there are no changesets to be published AND on trunk branch + if: needs.packages.outputs.hasChangesets == 'false' && github.ref == 'refs/heads/trunk' steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.gitignore b/.gitignore index 97d6e87fe..1d261323b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ node_modules .vercel .DS_Store .vscode -coverage \ No newline at end of file +coverage +tsconfig.tsbuildinfo diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..547c344eb --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,18 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Listen for Xdebug", + "type": "php", + "request": "launch", + "port": 9003, + "pathMappings": { + "/var/www/html/wp-content/plugins/headless-wp": "${workspaceFolder}/wp/headless-wp", + "/var/www/html/wp-content/plugins/wordpress-seo": "${workspaceFolder}/wp/headless-wp/vendor/wordpress-seo" + } + }, + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..3c107013d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "phpsab.composerJsonPath": "wp/headless-wp/composer.json", + "phpsab.fixerEnable": true, + "phpsab.snifferEnable": true, + "phpsab.snifferShowSources": true, + "[php]": { + "editor.defaultFormatter": "valeryanm.vscode-phpsab" + } +} \ No newline at end of file diff --git a/docs/.nvmrc b/docs/.nvmrc deleted file mode 100644 index 19c7bdba7..000000000 --- a/docs/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -16 \ No newline at end of file diff --git a/docs/documentation/01-Getting Started/headless-config.md b/docs/documentation/01-Getting Started/headless-config.md index 26304d7e1..17d81a995 100644 --- a/docs/documentation/01-Getting Started/headless-config.md +++ b/docs/documentation/01-Getting Started/headless-config.md @@ -24,7 +24,7 @@ module.exports = withHeadstartWPConfig(nextConfig); ``` :::caution Since `@headstartwp/next@1.2.0` you do not need to import `headstartwp.config.js` in `next.config.js` anymore, the framework will dynamically load the config. -:::caution +::: Here's a sample config file @@ -90,15 +90,15 @@ module.exports = { After adding a custom post type to the config, you will be able to fetch posts from the registered post type via the slug: ```js -usePost({ postType: ['book'] }); -usePosts({ postType:'book', perPage: 10 }); +queryPost({ params: { postType: ['book'] } }); +queryPosts({ params: { postType:'book', perPage: 10 } }); ``` The `single` option is required for several things including: - properly previewing custom post types when the "single" route is at a different prefix. E.g: `/book/da-vince-code` instead of `/da-vice-code`; In this case, the framework will use the `single` path to redirect the previewed post to the right path/route. -- Matching post path permalinks with the current URL. E.g: when fetching a single custom post type the framework will filter the returned posts to the one that matches the existing URL. Therefore, the framework needs to know the single prefix url for custom post types. This is required to properly handle parent pages that share the same child slug. See [post path mapping](/learn/data-fetching/usepost/#post-path-matching) for more info. +- Matching post path permalinks with the current URL. E.g: when fetching a single custom post type the framework will filter the returned posts to the one that matches the existing URL. Therefore, the framework needs to know the single prefix url for custom post types. This is required to properly handle parent pages that share the same child slug. -It is also possible to pass a function, when doing so the default post types (post and pages) will be passed to the function. The code snipped below will disable [post path mapping](/learn/data-fetching/usepost/#post-path-matching) to the default post types. +It is also possible to pass a function, when doing so the default post types (post and pages) will be passed to the function. The code snipped below will disable post path mapping to the default post types. ```js title="headstartwp.config.js" module.exports = { @@ -111,6 +111,27 @@ module.exports = { } ``` +Another use case is if you want your posts to sit at a different prefix (e.g: `/blog`), you can change your permalinks in WordPress (e.g: `/blog/%postname/`) and update the default `post` post type so that its `sigle` property is equal to `/blog`. + +```js title="headstartwp.config.js" +module.exports = { + sourceUrl: process.env.NEXT_PUBLIC_HEADLESS_WP_URL, + hostUrl: process.env.HOST_URL, + customPostTypes: (defaultPostTypes) => { + return defaultPostTypes.map((postType) => { + if (postType === 'post') { + return { + ...postType, + single: '/blog' + } + } + + return postType; + }; + } +} +``` + ## customTaxonomies To add support for custom taxonomies, add your custom taxonomy to the `customTaxonomies` setting in `headstartwp.config.js`. @@ -141,25 +162,21 @@ module.exports = { After adding a custom taxonomy to the config, you will be able to filter posts by the registered taxonomy or fetch terms from it. ```js -usePost({ postType: ['book'], genre: 'action' }); -usePosts({ postType:'book', genre: 'action', perPage: 10 }); -useTerms({ taxonomy: 'genre' }); +queryPost({ params: { postType: ['book'], genre: 'action' } }); +queryPosts({ params: { postType:'book', genre: 'action', perPage: 10 } }); +queryTerms({ params: { taxonomy: 'genre' } }); ``` Additionally, if you have an archive route such as `/blog` or `/books` filtering for all registered taxonomies works out of the box. For instance, take the headless config above the following page route: -```js title=src/pages/books/[[...path]].js -import { usePosts } from '@headstartwp/next'; -const BooksPage = () => { - const { data, error, loading } = usePosts({postType: 'book'}); - - if (error) { - return 'error'; - } +```js title=src/app/books/[[...path]]/page.tsx +import { queryPosts } from '@headstartwp/next/app'; - if (loading) { - return 'Loading...'; - } +const BooksPage = async ({ params }) => { + const { data } = await queryPosts({ + routeParams: await params, + params: { postType: 'book' } + }); return (