This commit is contained in:
Nilstrieb 2021-02-14 15:44:50 +01:00
parent 295bdd927c
commit 6b39d6b79a
7 changed files with 17 additions and 12 deletions

41
src/PlaneInfo.js Normal file
View file

@ -0,0 +1,41 @@
import React, {Component} from 'react';
import planes from './planes.json';
import './plane.css';
class Planes extends Component {
render() {
const loc = this.props.location.pathname;
const planeName = loc.replaceAll('/flugzeug/', '');
let plane;
for (const e of planes) {
if (e.category + e.name === planeName) {
plane = e;
break;
}
}
let content;
if (plane === undefined) {
content =
<div>
<h2>Flugzeug nicht gefunden.</h2>
</div>
;
} else {
const imgPath = process.env.PUBLIC_URL + '/img/' + plane.category + plane.img;
content =
<div>
<h2>{plane.name}</h2>
<img src={imgPath} alt={'Bild von ' + plane.name} className="plane-image"/>
<p>{plane.description}</p>
</div>
;
}
return (
content
);
}
}
export default Planes;