Skip to content

Commit

Permalink
feat(homepage): add admin page footer links preview
Browse files Browse the repository at this point in the history
  • Loading branch information
ben196888 committed Sep 20, 2023
1 parent d93c365 commit 9605a04
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions homepage/src/pages/admin/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Headline from '../../components/headline';
import Section from '../../components/section';
import TwoColumns from '../../components/twoColumns';
import ThreeColumns from '../../components/threeColumns';
import FooterLinks from '../../layouts/footer/footerLinks';

const PagePreview = ({ entry }) => {
const layoutList = entry.getIn(['data', 'layout_list']);
Expand Down Expand Up @@ -115,6 +116,22 @@ const PagePreview = ({ entry }) => {
return <div>{sections}</div>;
};

const FooterPreview = ({ entry }) => {
const footer = entry.getIn(['data', 'footer']);
const links = footer
?.get('links')
.map((link) => {
return {
displayText: link.get('display_text')?.toString(),
url: link.get('url')?.toString(),
};
})
.toArray();
return (
<FooterLinks links={links} />
);
};

const CMS = dynamic(
() =>
import('decap-cms-app').then((cms) => {
Expand All @@ -134,6 +151,7 @@ const CMS = dynamic(
cms.registerPreviewStyle('/css/style.css');

cms.registerPreviewTemplate('pages', PagePreview);
cms.registerPreviewTemplate('footer', FooterPreview);
}),
{ ssr: false, loading: () => <p>Loading...</p> },
);
Expand Down

0 comments on commit 9605a04

Please sign in to comment.