Skip to content

Commit

Permalink
Merge branch 'develop' into feature/handle-single-and-archive-same-route
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasio committed Aug 9, 2023
2 parents 857878d + c58d618 commit 90a5794
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .changeset/curly-apricots-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@headstartwp/next": patch
---

Fix: only convertUrls if url starts with sourceUrl
2 changes: 2 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
},
"changesets": [
"bright-jokes-learn",
"curly-apricots-stare",
"lovely-chicken-sparkle",
"mighty-stingrays-pay",
"silent-kiwis-compare",
"two-cats-vanish"
]
}
23 changes: 12 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @headstartwp/core

## 1.1.0-next.1

### Patch Changes

- 1494a332: Further Optimize next.js props by removing yoast seo bloat.

## 1.1.0-next.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@headstartwp/core",
"version": "1.1.0-next.0",
"version": "1.1.0-next.1",
"description": "`@headstartwp/core` is the core package that houses framework-agnostic components and utilities for building headless sites with WordPress.",
"homepage": "https://github.com/10up/headstartwp/blob/develop/packages/core/README.md",
"license": "MIT",
Expand Down
9 changes: 9 additions & 0 deletions packages/next/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @headstartwp/next

## 1.1.0-next.1

### Patch Changes

- 232f4e68: Fix: only convertUrls if url starts with sourceUrl
- 1494a332: Further Optimize next.js props by removing yoast seo bloat.
- Updated dependencies [1494a332]
- @headstartwp/core@1.1.0-next.1

## 1.1.0-next.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@headstartwp/next",
"version": "1.1.0-next.0",
"version": "1.1.0-next.1",
"description": "`@headstartwp/next` is the Next.js bindings for the headless framework.",
"homepage": "https://github.com/10up/headstartwp/blob/develop/packages/next/README.md",
"license": "MIT",
Expand Down Expand Up @@ -48,8 +48,8 @@
"lint": "eslint src"
},
"dependencies": {
"@headstartwp/core": "^1.1.0-next.0",
"deepmerge": "^4.3.1",
"@headstartwp/core": "^1.1.0-next.1",
"modify-source-webpack-plugin": "^4.1.0",
"loader-utils": "^3.2.0",
"schema-utils": "^4.0.0"
Expand Down
11 changes: 9 additions & 2 deletions packages/next/src/components/Yoast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ import {
import { useSettings } from '@headstartwp/core/react';
import Head from 'next/head';

function convertUrl(url: string, hostUrl: string, sourceUrl: string) {
return `${hostUrl}${removeSourceUrl({ link: url, backendUrl: sourceUrl })}`;
export function convertUrl(url: string, hostUrl: string, sourceUrl: string) {
if (!url.startsWith(sourceUrl)) {
return url;
}

return `${hostUrl}${removeSourceUrl({
link: url.replace(/\/?$/, '/'),
backendUrl: sourceUrl,
})}`;
}

type Props = {
Expand Down
25 changes: 25 additions & 0 deletions packages/next/src/components/__tests__/Yoast.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { convertUrl } from '../Yoast';

describe('convertUrl', () => {
it('root works without trailing slash', () => {
expect(
convertUrl('https://test.com/test', 'https://test.test.com', 'https://test.com/test'),
).toBe('https://test.test.com/');
});

it('root works with trailing slash', () => {
expect(
convertUrl('https://test.com/test/', 'https://test.test.com', 'https://test.com/test'),
).toBe('https://test.test.com/');
});

it('external url returns external url', () => {
expect(
convertUrl(
'https://external.com/test',
'https://test.test.com',
'https://test.com/test',
),
).toBe('https://external.com/test');
});
});
4 changes: 2 additions & 2 deletions projects/wp-multisite-i18n-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"lint": "eslint ."
},
"dependencies": {
"@headstartwp/core": "^1.1.0-next.0",
"@headstartwp/next": "^1.1.0-next.0",
"@headstartwp/core": "^1.1.0-next.1",
"@headstartwp/next": "^1.1.0-next.1",
"@linaria/babel-preset": "^4.4.5",
"@linaria/core": "^4.2.10",
"@linaria/react": "^4.3.8",
Expand Down
4 changes: 2 additions & 2 deletions projects/wp-multisite-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"lint": "eslint ."
},
"dependencies": {
"@headstartwp/core": "^1.1.0-next.0",
"@headstartwp/next": "^1.1.0-next.0",
"@headstartwp/core": "^1.1.0-next.1",
"@headstartwp/next": "^1.1.0-next.1",
"@linaria/babel-preset": "^4.4.5",
"@linaria/core": "^4.2.10",
"@linaria/react": "^4.3.8",
Expand Down
4 changes: 2 additions & 2 deletions projects/wp-nextjs-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"lint": "eslint ."
},
"dependencies": {
"@headstartwp/core": "^1.1.0-next.0",
"@headstartwp/next": "^1.1.0-next.0",
"@headstartwp/core": "^1.1.0-next.1",
"@headstartwp/next": "^1.1.0-next.1",
"@linaria/babel-preset": "^4.4.5",
"@linaria/core": "^4.2.10",
"@linaria/react": "^4.3.8",
Expand Down
4 changes: 2 additions & 2 deletions projects/wp-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"lint": "eslint ."
},
"dependencies": {
"@headstartwp/core": "^1.1.0-next.0",
"@headstartwp/next": "^1.1.0-next.0",
"@headstartwp/core": "^1.1.0-next.1",
"@headstartwp/next": "^1.1.0-next.1",
"@10up/next-redis-cache-provider": "^0.1.5",
"@linaria/babel-preset": "^4.4.5",
"@linaria/core": "^4.2.10",
Expand Down

0 comments on commit 90a5794

Please sign in to comment.