Skip to content

Commit

Permalink
subpath react
Browse files Browse the repository at this point in the history
  • Loading branch information
raed667 committed Dec 13, 2023
1 parent 350f574 commit e75d160
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ jobs:
run: yarn build

- name: Build example playgrounds
run: yarn build:playgrounds -- -- --public-url=/recommend/pr-preview/pr-162/demo/dist/
env:
SUB_PATH: /recommend/pr-preview/pr-${{ github.event.number }}/demo/dist/
run: yarn build:playgrounds -- -- --public-url=/recommend/pr-preview/pr-${{ github.event.number }}/demo/dist/

- name: Deploy preview
uses: rossjrw/pr-preview-action@v1
Expand Down
36 changes: 21 additions & 15 deletions examples/demo/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,28 @@ import '@algolia/ui-components-horizontal-slider-theme';
import './App.css';
import './Recommend.css';

const router = createBrowserRouter([
const router = createBrowserRouter(
[
{
path: '/',
element: <Root />,
children: [
{
path: '/',
element: <HomePage />,
},
{
path: '/product/:id',
element: <ProductPage />,
},
],
},
],
{
path: '/',
element: <Root />,
children: [
{
path: '/',
element: <HomePage />,
},
{
path: '/product/:id',
element: <ProductPage />,
},
],
},
]);
// needed for github pages subdirectory
basename: process.env.SUB_PATH ?? '/',
}
);

ReactDOM.render(
<React.StrictMode>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"playground-js:start": "yarn workspace @algolia/recommend-js-example start",
"playground-templating:start": "yarn workspace @algolia/recommend-templating-example start",
"playground:start": "yarn workspace @algolia/recommend-react-example start",
"build:playgrounds": "lerna run build --scope=\"'@algolia/recommend-*-example'\"",
"build:playgrounds": "lerna run build --scope=\"'@algolia/recommend-react-example'\"",
"prepare": "lerna run prepare --no-private",
"release": "shipjs prepare",
"test:size": "bundlesize",
Expand Down

0 comments on commit e75d160

Please sign in to comment.