Skip to content

Commit

Permalink
fix: guide
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Dec 10, 2024
1 parent 852e3a7 commit 6e7c18c
Show file tree
Hide file tree
Showing 21 changed files with 1,936 additions and 497 deletions.
18 changes: 12 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,38 @@
"@react-google-maps/api": "^2.20.3",
"chart.js": "^4.4.2",
"metamask-react": "^2.7.0",
"react": "^18.2",
"property-information": "^6.5.0",
"react": "^19",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2",
"react-dom": "^19",
"react-helmet": "^6.1.0",
"react-icons": "^5.4.0",
"react-loading-skeleton": "^3.5.0",
"react-markdown": "^9.0.1",
"react-router-dom": "^6.26.1",
"remark-gfm": "^4.0.0",
"viem": "^2.21.54",
"web3": "^4.16.0"
},
"devDependencies": {
"@parcel/reporter-bundle-analyzer": "^2.11.0",
"@parcel/transformer-typescript-tsc": "^2.12.0",
"@types/react": "^18.2",
"@types/react-dom": "^18.2",
"@parcel/transformer-typescript-tsc": "^2.13.0",
"@types/react": "^19",
"@types/react-dom": "^19",
"@types/react-helmet": "^6.1.11",
"@typescript-eslint/eslint-plugin": "^8",
"@typescript-eslint/parser": "^8",
"buffer": "^5.5.0||^6.0.0",
"eslint": "^8",
"eslint-config-prettier": "^9.1",
"parcel": "^2.12",
"parcel": "^2.13",
"postcss": "^8.4",
"prettier": "^3",
"process": "^0.11.10",
"tailwindcss": "^3.4",
"typescript": "^5.3"
},
"@parcel/resolver-default": {
"packageExports": true
}
}
5 changes: 5 additions & 0 deletions sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@
<lastmod>2025-01-10</lastmod>
<priority>1.00</priority>
</url>
<url>
<loc>https://ekokedao.com/guide/reward</loc>
<lastmod>2025-01-10</lastmod>
<priority>1.00</priority>
</url>
</urlset>
67 changes: 65 additions & 2 deletions src/js/components/App/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Route as RouterRoute, Routes } from 'react-router-dom';

import { Route } from '../../utils/routes';
import SeoEngine from '../SeoEngine';
import Container from '../reusable/Container';

// pages
const Home = React.lazy(() => import('./pages/Home'));
Expand All @@ -25,11 +26,33 @@ const ProfileContracts = React.lazy(

// Guide
const Guide = React.lazy(() => import('./pages/Guide'));
const GuideArchitecture = React.lazy(
() => import('./pages/Guide/pages/Architecture'),
);
const GuideDeferredData = React.lazy(
() => import('./pages/Guide/pages/DeferredData'),
);
const GuideDeferredMinter = React.lazy(
() => import('./pages/Guide/pages/DeferredMinter'),
);
const GuideDeferred = React.lazy(() => import('./pages/Guide/pages/Deferred'));
const GuideEkoke = React.lazy(() => import('./pages/Guide/pages/Ekoke'));
const GuideMarketplace = React.lazy(
() => import('./pages/Guide/pages/Marketplace'),
);
const GuideRewardPool = React.lazy(
() => import('./pages/Guide/pages/RewardPool'),
);
const GuideReward = React.lazy(() => import('./pages/Guide/pages/Reward'));
const GuideWhitepaper = React.lazy(
() => import('./pages/Guide/pages/Whitepaper'),
);
const GuideFaq = React.lazy(() => import('./pages/Guide/pages/Faq'));

const AppRouter = () => (
<>
<SeoEngine />
<main>
<Container.Container>
<React.Suspense fallback={null}>
<Routes>
<RouterRoute path={Route.url(Route.HOME)} element={<Home />} />
Expand Down Expand Up @@ -57,12 +80,52 @@ const AppRouter = () => (

{/* Guide */}
<RouterRoute path={Route.url(Route.GUIDE)} element={<Guide />} />
<RouterRoute
path={Route.url(Route.GUIDE_ARCHITECTURE)}
element={<GuideArchitecture />}
/>
<RouterRoute
path={Route.url(Route.GUIDE_CANISTERS_DATA)}
element={<GuideDeferredData />}
/>
<RouterRoute
path={Route.url(Route.GUIDE_CANISTERS_MINTER)}
element={<GuideDeferredMinter />}
/>
<RouterRoute
path={Route.url(Route.GUIDE_CONTRACTS_DEFERRED)}
element={<GuideDeferred />}
/>
<RouterRoute
path={Route.url(Route.GUIDE_CONTRACTS_EKOKE)}
element={<GuideEkoke />}
/>
<RouterRoute
path={Route.url(Route.GUIDE_CONTRACTS_MARKETPLACE)}
element={<GuideMarketplace />}
/>
<RouterRoute
path={Route.url(Route.GUIDE_CONTRACTS_REWARD_POOL)}
element={<GuideRewardPool />}
/>
<RouterRoute
path={Route.url(Route.GUIDE_REWARD)}
element={<GuideReward />}
/>
<RouterRoute
path={Route.url(Route.GUIDE_WHITEPAPER)}
element={<GuideWhitepaper />}
/>
<RouterRoute
path={Route.url(Route.GUIDE_FAQ)}
element={<GuideFaq />}
/>

{/* 404 */}
<RouterRoute path="*" element={<NotFound />} />
</Routes>
</React.Suspense>
</main>
</Container.Container>
</>
);

Expand Down
2 changes: 1 addition & 1 deletion src/js/components/App/pages/About/Team.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Team = () => (
<Member
image={'http://placekittens.com/150/150'}
name={'Michele Sessa'}
role={'CTO & Software Engineer'}
role={'Marketing manager'}
>
<Paragraph.Default>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
Expand Down
127 changes: 127 additions & 0 deletions src/js/components/App/pages/Guide/MdPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import * as React from 'react';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import 'property-information';
import * as Icon from 'react-icons/fa6';

import { useAppContext } from '../../AppContext';
import Container from '../../../reusable/Container';
import Wrapper from './Wrapper';
import Link from '../../../reusable/Link';

interface Props {
githubUrl: string;
url: string;
}

const redirectRelativeImgToGithub = (url: string, src: string) => {
// get base of url
let base = url.split('/').slice(0, -1).join('/');

if (src.startsWith('./')) {
// replace ./
return src.replace('./', `${base}/`);
}

if (src.indexOf('../') === 0) {
// resolve `../` by removing last part of base
base = url;
while (src.indexOf('../') === 0) {
src = src.replace('../', '');
base = base.split('/').slice(0, -1).join('/');
}

return `${base}/${src}`;
}

return src;
};

const redirectHref = (href: string) => {
return href.replace('.md', '').toLowerCase();
};

const MdPage = ({ url, githubUrl }: Props) => {
const { setAppError } = useAppContext();
const [md, setMd] = React.useState('');

React.useEffect(() => {
fetch(url)
.then((res) => res.text())
.then(setMd)
.catch((err) => {
console.error('Failed to load page', err);
setAppError('Failed to load page');
});
}, [url]);

return (
<Wrapper>
<Container.Container>
<Container.FlexRow className="items-end justify-end w-full">
<Container.Container>
<Link.Button href={githubUrl} target="_blank">
<Icon.FaGithub className="inline mr-2" size={24} /> View on GitHub
</Link.Button>
</Container.Container>
</Container.FlexRow>
<Container.Container className={'markdown'}>
{md && (
<ReactMarkdown
components={{
a: function ({ node, ...props }) {
if (!node) {
return null;
}
if (!node.properties.href) {
return null;
}
if (typeof node.properties.href !== 'string') {
return null;
}
const href = node.properties.href;

props.href = redirectHref(href);

return (
<a href={props.href} target={props.target}>
{props.children as unknown as any}
</a>
);
},
img: function ({ node, ...props }) {
if (!node) {
return null;
}
if (!node.properties.src) {
return null;
}
if (typeof node.properties.src !== 'string') {
return null;
}
const src = node.properties.src;

props.src = redirectRelativeImgToGithub(url, src);

return (
<img
src={props.src}
alt={props.alt}
width={props.width}
height={props.height}
/>
);
},
}}
remarkPlugins={[remarkGfm]}
>
{md}
</ReactMarkdown>
)}
</Container.Container>
</Container.Container>
</Wrapper>
);
};

export default MdPage;
Loading

0 comments on commit 6e7c18c

Please sign in to comment.