Skip to content

Commit c3da22c

Browse files
authored
Update app for latest Applura client and SSR server interfaces (#21)
2 parents 917b1fd + 4be7d75 commit c3da22c

File tree

16 files changed

+3415
-901
lines changed

16 files changed

+3415
-901
lines changed

esbuild.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const esbuild = require('esbuild');
2+
3+
esbuild.build({
4+
entryPoints: ['src/render.js'],
5+
bundle: true,
6+
minify: true,
7+
format: 'esm',
8+
outfile: 'dist/render.js',
9+
loader: {
10+
'.js': 'jsx',
11+
'.pcss': 'empty',
12+
},
13+
}).catch(() => process.exit(1));

package-lock.json

Lines changed: 3312 additions & 762 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,24 @@
88
"build": "npm run build:client && npm run build:server && npm run build:assets",
99
"build:watch": "webpack --watch",
1010
"build:client": "webpack --config webpack.config.cjs",
11-
"build:server": "webpack --config webpack.config.server.cjs",
11+
"build:server": "esbuild src/render.js --loader:.js=jsx --loader:.pcss=empty --bundle --minify --format=esm --outfile=dist/render.js",
1212
"build:assets": "rm -rf dist/static dist/index.html && cp -r src/index.html src/static dist/"
1313
},
1414
"author": "Applura, Inc",
1515
"license": "MIT",
1616
"dependencies": {
1717
"dayjs": "^1.11.13",
18+
"esbuild": "^0.25.5",
1819
"react": "^18.2.0",
1920
"react-dom": "^18.2.0"
2021
},
2122
"devDependencies": {
23+
"@babel/preset-env": "^7.28.0",
2224
"@babel/preset-react": "^7.22.15",
2325
"autoprefixer": "^10.4.20",
2426
"babel-loader": "^9.1.3",
2527
"css-loader": "^7.1.2",
28+
"mini-css-extract-plugin": "^2.9.2",
2629
"postcss": "^8.5.1",
2730
"postcss-loader": "^8.1.1",
2831
"postcss-minify": "^1.1.0",

src/app.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const PageTypes = {
2121
*/
2222
const App = ({ resource, problem }) => {
2323
if (problem) {
24-
const statusCode = problem.response.status;
24+
const statusCode = problem.status;
2525
const phrases = {
2626
403: 'Sign in or get out!',
2727
404: "Oops, this is not the page you're looking for.",

src/component/cards/cards.jsx

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
import React from "react";
22
import './cards.pcss';
3-
import Link from "../link/link.jsx";
43

5-
/**
6-
* Nav renders a navigation resource.
7-
*
8-
* @param resource
9-
*/
104
const Cards = ({ cards }) => {
11-
return <div className="cards">
12-
{cards.data.map(({ title, teaserIcon, teaserText, links }, i) => (
13-
<Link key={i} title={title} href={links.get('canonical').href}>
14-
<div key={i} className="card">
15-
<div className={'card-icon ' + teaserIcon}></div>
16-
<div className="card-content">
17-
<div className="card-title">{title}</div>
18-
<div className="card-description">{teaserText}</div>
5+
return (
6+
<div className="cards">
7+
{cards.map(({ title, teaserIcon, teaserText, links }, i) => (
8+
<a href={links.canonical.href}>
9+
<div className="card">
10+
<div className={`card-icon ${teaserIcon}`}></div>
11+
<div className="card-content">
12+
<div className="card-title">{title}</div>
13+
<div className="card-description">{teaserText}</div>
14+
</div>
1915
</div>
20-
</div>
21-
</Link>
22-
))}
23-
</div>
16+
</a>
17+
))}
18+
</div>
19+
);
2420
};
2521

2622
export default Cards;

src/component/header/header.jsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import React from "react";
22
import Nav from "./../nav/nav.jsx";
33
import "./header.pcss";
4-
import Link from "../link/link.jsx";
54

65
const Header = ({ menu, links }) => {
7-
const edit = links.get('edit-form');
6+
const edit = links['edit-form'];
87
return <header className="header">
98
<div className="header-content">
10-
<Nav menu={ menu.data } />
11-
<div className="actions">
12-
{edit && <Link href={edit.href} title={"Edit page"} className={"btn-primary"}/>}
13-
</div>
9+
<Nav menu={ menu } />
10+
{edit && (
11+
<div className="actions">
12+
<a href={edit.href} title="Edit page" className="btn-primary">Edit page</a>
13+
</div>
14+
)}
1415
</div>
1516
</header>
1617
};
1718

18-
export default Header;
19+
export default Header;

src/component/link/link.jsx

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/component/nav/nav.jsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import "./nav.pcss";
77
* @param resource
88
*/
99
const Nav = ({ menu }) => {
10-
return <div className="navigation">
11-
<ul className="menu">
12-
{menu.items.map(({ href, title }, i) => (
13-
<li key={i}><a href={ href }>{ title }</a></li>
14-
))}
15-
</ul>
16-
</div>
10+
return (
11+
<div className="navigation">
12+
<ul className="menu">
13+
{menu.items.map(({ href, title }, i) => (
14+
<li key={i}><a href={ href }>{ title }</a></li>
15+
))}
16+
</ul>
17+
</div>
18+
)
1719
};
1820

1921
export default Nav;

src/component/short-cards/short-cards.jsx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
import React from "react";
22
import "./short-cards.pcss";
3-
import Link from "./../link/link.jsx";
43

54
/**
65
* Nav renders a navigation resource.
7-
*
8-
* @param resource
96
*/
107
const ShortCards = ({ cards }) => {
11-
// Get the current URL
12-
const currentUrl = window.location.href;
13-
148
return (
159
<div className="short-cards">
16-
{cards.data.map(({ title, teaserIcon, teaserText, links }, i) => {
17-
const linkHref = new URL(links.get('canonical').href, window.location.origin).href;
18-
// Check if the resolved link matches the current URL
19-
const isActive = linkHref === currentUrl;
10+
{cards.map(({ id, title, teaserIcon, teaserText, links }, i) => {
2011
return (
21-
<Link key={i} className={`short-card-link ${isActive ? 'active' : ''}`} title={title} href={links.get('canonical').href}>
22-
<div key={i} className={'short-card'}>
23-
<div className={'short-card-icon ' + teaserIcon}></div>
12+
<a
13+
key={id}
14+
className={`short-card-link`}
15+
title={title}
16+
href={links.canonical.href}
17+
>
18+
<div className="short-card">
19+
<div className={`short-card-icon ${teaserIcon}`}></div>
2420
<div className="short-card-title">{title}</div>
2521
</div>
26-
</Link>
22+
</a>
2723
);
2824
})}
2925
</div>

src/component/text/text.jsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ import ProcessedHTML from "../../component/processed-html/processed-html.jsx";
77
* @param resource
88
*/
99
const Text = ({ components }) => {
10-
const {heading, content} = components.data;
10+
const { heading, content } = components;
1111
return <div className="text-wrapper">
12-
<h2 className="content-title">{heading}</h2>
13-
<div className="content-description">
14-
<ProcessedHTML html={content}/>
15-
</div>
12+
{heading ?
13+
<h2 className="content-title">{heading}</h2>
14+
: null
15+
}
16+
{content ?
17+
<div className="content-description">
18+
<ProcessedHTML html={content}/>
19+
</div>
20+
: null
21+
}
1622
</div>
1723
};
1824

0 commit comments

Comments
 (0)