Removed client-side markdown rendering
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
<header>
|
||||
<h1 class="text centered">Credits</h1>
|
||||
</header>
|
||||
|
||||
## MERN-template
|
||||
|
||||
The MERN-template developed by Kayne Ruse, KR Game Studios
|
||||
|
||||
[https://github.com/krgamestudios/MERN-template](https://github.com/krgamestudios/MERN-template)
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<header>
|
||||
<h1 class="text centered">Privacy Policy</h1>
|
||||
</header>
|
||||
|
||||
@@ -5,7 +5,6 @@ import { TokenContext } from './utilities/token-provider';
|
||||
|
||||
//library components
|
||||
import LazyRoute from './utilities/lazy-route';
|
||||
import MarkdownPage from './utilities/markdown-page';
|
||||
|
||||
//styling
|
||||
import '../styles/styles.css';
|
||||
@@ -34,8 +33,8 @@ const App = props => {
|
||||
<LazyRoute path='/admin' component={() => import('./administration/admin')} />
|
||||
<LazyRoute path='/mod' component={() => import('./administration/mod')} />
|
||||
|
||||
<LazyRoute path='/privacypolicy' component={async () => () => <MarkdownPage content={require('../markdown/privacy-policy.md').default} />} />
|
||||
<LazyRoute path='/credits' component={async () => () => <MarkdownPage content={require('../markdown/credits.md').default} />} />
|
||||
<LazyRoute path='/privacypolicy' component={() => import('./static/privacy-policy')} />
|
||||
<LazyRoute path='/credits' component={() => import('./static/credits')} />
|
||||
|
||||
<LazyRoute path='*' component={() => import('./not-found')} />
|
||||
</Switch>
|
||||
|
||||
@@ -5,7 +5,6 @@ import ApplyToBody from './utilities/apply-to-body';
|
||||
|
||||
import { TokenContext } from './utilities/token-provider';
|
||||
|
||||
import MarkdownPanel from './utilities/markdown-panel';
|
||||
import Logout from './accounts/panels/logout';
|
||||
|
||||
const Dashboard = props => {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import dateFormat from 'dateformat';
|
||||
|
||||
import MarkdownPanel from '../utilities/markdown-panel';
|
||||
|
||||
const NewsFeed = props => {
|
||||
const [articles, setArticles] = useState([]);
|
||||
const aborter = useRef(new AbortController()); //BUGFIX: double-renders = double fetches + react update after unmount
|
||||
@@ -29,6 +27,7 @@ const NewsFeed = props => {
|
||||
<div className='panel'>
|
||||
<h1 className='text centered'>News Feed</h1>
|
||||
{articles.map((article, index) => {
|
||||
console.log(article)
|
||||
return (
|
||||
<div key={index} className='panel'>
|
||||
<hr />
|
||||
@@ -40,7 +39,7 @@ const NewsFeed = props => {
|
||||
<span>Published {dateFormat(article.createdAt, 'fullDate')}</span>
|
||||
}</em></p>
|
||||
<br />
|
||||
<MarkdownPanel style={{whiteSpace: 'pre-wrap'}} content={article.body} />
|
||||
<div dangerouslySetInnerHTML={{ __html: article.rendered }} />
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import React from 'react';
|
||||
|
||||
const Static = props => {
|
||||
return (
|
||||
<>
|
||||
<header>
|
||||
<h1 className='text centered'>Credits</h1>
|
||||
</header>
|
||||
<h2>MERN-template</h2>
|
||||
<p>The <a href='https://github.com/krgamestudios/MERN-template'>MERN-template</a> developed by Kayne Ruse, KR Game Studios</p>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Static;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
|
||||
const Static = props => {
|
||||
return (
|
||||
<header>
|
||||
<h1 className="text centered">Privacy Policy</h1>
|
||||
</header>
|
||||
);
|
||||
};
|
||||
|
||||
export default Static;
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import ApplyToBody from '../utilities/apply-to-body';
|
||||
|
||||
import MarkdownPanel from './markdown-panel';
|
||||
|
||||
const MarkdownPage = props => {
|
||||
return (
|
||||
<>
|
||||
<ApplyToBody className='dashboard' />
|
||||
<div className='page'>
|
||||
<div className='central panel'>
|
||||
<MarkdownPanel uri={props.uri} content={props.content} />
|
||||
<Link to='/' className='text centered'>Return Home</Link>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
};
|
||||
|
||||
export default MarkdownPage;
|
||||
@@ -1,35 +0,0 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import rehypeRaw from 'rehype-raw';
|
||||
|
||||
const Markdown = props => {
|
||||
//content?
|
||||
let [contentHook, setContentHook] = useState(null);
|
||||
|
||||
//check arguments
|
||||
if (!props.content) {
|
||||
if (!props.uri) {
|
||||
throw 'Markdown requires either content or uri prop';
|
||||
}
|
||||
|
||||
//once
|
||||
useEffect(() => {
|
||||
fetch(props.uri)
|
||||
.then(blob => blob.text())
|
||||
.then(blob => setContentHook(blob))
|
||||
.catch(e => console.error(e))
|
||||
;
|
||||
}, []);
|
||||
}
|
||||
|
||||
//assume raw info
|
||||
else if (!contentHook) {
|
||||
setContentHook(props.content);
|
||||
}
|
||||
|
||||
return (
|
||||
<ReactMarkdown rehypePlugins={[rehypeRaw]} props={{...props}}>{contentHook}</ReactMarkdown>
|
||||
);
|
||||
};
|
||||
|
||||
export default Markdown;
|
||||
Reference in New Issue
Block a user