Update basic page.
This commit is contained in:
parent
0777027a4b
commit
af9ab5a4a3
@ -1,15 +1,19 @@
|
|||||||
import React, {useState, useEffect} from 'react';
|
import React, {useState, useEffect} from 'react';
|
||||||
import parse from 'html-react-parser'
|
import parse from 'html-react-parser'
|
||||||
|
|
||||||
import ScrollSpy from '../UI/ScrollSpy';
|
// import ScrollSpy from '../UI/ScrollSpy';
|
||||||
|
|
||||||
const BasicPage = (props) => {
|
const BasicPage = (props) => {
|
||||||
|
const [theme, setTheme] = useState(
|
||||||
|
localStorage.getItem('theme') || 'light'
|
||||||
|
);
|
||||||
|
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
const [isLoaded, setIsLoaded] = useState(false);
|
const [isLoaded, setIsLoaded] = useState(false);
|
||||||
const [items, setItems] = useState([]);
|
const [items, setItems] = useState([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch("http://localhost:8080/jsonapi/node/page/" + props.id)
|
fetch("http://localhost:5218/page/" + props.id)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(
|
.then(
|
||||||
(result) => {
|
(result) => {
|
||||||
@ -30,19 +34,18 @@ const BasicPage = (props) => {
|
|||||||
} else {
|
} else {
|
||||||
console.log(items)
|
console.log(items)
|
||||||
|
|
||||||
const title = items['data']['attributes']['title']
|
const title = items[0]['title']
|
||||||
const subtitle = items['data']['attributes']['field_subtitle']
|
const subtitle = items[0]['subtitle']
|
||||||
const body = items['data']['attributes']['body']['processed']
|
const body = items[0]['content']
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='row'>
|
<div className='row'>
|
||||||
<ScrollSpy/>
|
{/* <ScrollSpy/> */}
|
||||||
<div className="scrollspy-example col-6 offset-3" data-bs-spy="scroll" data-bs-target="#list-example" data-bs-smooth-scroll="true" tabIndex="0">
|
<div className={`scrollspy-example col-6 offset-3 bg-${theme}`} data-bs-spy="scroll" data-bs-target="#list-example" data-bs-smooth-scroll="true" tabIndex="0">
|
||||||
<section id="list-skills" className="content-section">
|
<section id="list-skills" className={`text-${theme}`}>
|
||||||
<h2 className="text-primary">{title}</h2>
|
<h2 className={`text-primary-${theme}`}>{title}</h2>
|
||||||
<h4 class="text-secondary">{subtitle}</h4>
|
<h4 className={`text-secondary-${theme}`}>{subtitle}</h4>
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
{parse(body)}
|
{parse(body)}
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user