-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/add-logo-data-in-cms-footer-collection
- Loading branch information
Showing
25 changed files
with
169 additions
and
443 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ type: job | |
tags: | ||
- civil servants | ||
--- | ||
Public Servant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ type: job | |
tags: | ||
- engineer | ||
--- | ||
Engineer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ type: job | |
tags: | ||
- writer | ||
--- | ||
Copywriter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ type: job | |
tags: | ||
- legal | ||
--- | ||
Legal Personnel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ type: job | |
tags: | ||
- designer | ||
--- | ||
AD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ type: job | |
tags: | ||
- marketing | ||
--- | ||
Marketing PR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ type: job | |
tags: | ||
- advocator | ||
--- | ||
Advocator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ type: job | |
tags: | ||
- civil servants | ||
--- | ||
公務 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ type: job | |
tags: | ||
- engineer | ||
--- | ||
工程 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ type: job | |
tags: | ||
- writer | ||
--- | ||
文字 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ type: job | |
tags: | ||
- legal | ||
--- | ||
法務 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ type: job | |
tags: | ||
- designer | ||
--- | ||
美術 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ type: job | |
tags: | ||
- marketing | ||
--- | ||
行銷 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,3 @@ type: job | |
tags: | ||
- advocator | ||
--- | ||
議題 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import dynamic from 'next/dynamic'; | ||
import PagePreview from './preview/PagePreview'; | ||
import FooterPreview from './preview/FooterPreview'; | ||
import CardPreview from './preview/CardPreview'; | ||
|
||
import config from './config.json'; | ||
|
||
const withAssetsByLocale = (Component, assetsByLocale) => { | ||
const WrappedComponent = (props) => ( | ||
<Component {...props} assetsByLocale={assetsByLocale} /> | ||
); | ||
WrappedComponent.displayName = `withAssetsByLocale(${Component.displayName})`; | ||
return WrappedComponent; | ||
}; | ||
|
||
const DecapCms = (assetsByLocale) => | ||
dynamic( | ||
() => | ||
import('decap-cms-app').then((cms) => { | ||
cms.init({ config }); | ||
cms.registerPreviewStyle( | ||
'https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css', | ||
); | ||
cms.registerPreviewStyle( | ||
'https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/all.min.css', | ||
); | ||
cms.registerPreviewStyle( | ||
'https://fonts.googleapis.com/css?family=Montserrat:400,700', | ||
); | ||
cms.registerPreviewStyle( | ||
'https://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700', | ||
); | ||
cms.registerPreviewStyle('/css/style.css'); | ||
|
||
cms.registerPreviewTemplate( | ||
'pages', | ||
withAssetsByLocale(PagePreview, assetsByLocale), | ||
); | ||
cms.registerPreviewTemplate( | ||
'footer', | ||
withAssetsByLocale(FooterPreview, assetsByLocale), | ||
); | ||
cms.registerPreviewTemplate( | ||
'cards', | ||
withAssetsByLocale(CardPreview, assetsByLocale), | ||
); | ||
}), | ||
{ ssr: false, loading: () => <p>Loading...</p> }, | ||
); | ||
|
||
export default DecapCms; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Card from '../../components/cards/card'; | ||
import { processCard } from '../../lib/processCard'; | ||
|
||
const CardPreview = ({ entry, getAsset, assetsByLocale }) => { | ||
const locale = 'en'; | ||
const assets = assetsByLocale[locale]; | ||
|
||
const data = entry.getIn(['data']).toJS(); | ||
const content = data.body; | ||
|
||
const card = processCard({ data, content }, assets.cards); | ||
|
||
card.data.image = getAsset(card.data.image).toString(); | ||
|
||
return <Card card={card} />; | ||
}; | ||
|
||
export default CardPreview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import FooterLinks from '../../layouts/footer/footerLinks'; | ||
|
||
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} />; | ||
}; | ||
|
||
export default FooterPreview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { componentMapper } from '../../lib/componentMapper'; | ||
import contentMapper from '../../layouts/contentMapper'; | ||
|
||
const PagePreview = ({ entry, assetsByLocale }) => { | ||
const locale = 'en'; | ||
const assets = assetsByLocale[locale]; | ||
|
||
const layoutList = entry.getIn(['data', 'layout_list']); | ||
const sections = layoutList?.map((layout) => { | ||
const component = componentMapper(layout.toJS(), assets.cards); | ||
return contentMapper(component); | ||
}); | ||
return <div>{sections}</div>; | ||
}; | ||
|
||
export default PagePreview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import Head from 'next/head'; | ||
import Script from 'next/script'; | ||
|
||
import { fetchCards } from '../lib/fetchCards'; | ||
import { processCard } from '../lib/processCard'; | ||
import DecapCms from '../CMS/DecapCms'; | ||
|
||
/** | ||
* | ||
* @type {import('next').GetStaticProps} | ||
*/ | ||
export const getStaticProps = async ({ locales }) => { | ||
const assetsTasks = locales.map(async (locale) => { | ||
const rawCards = fetchCards(locale); | ||
const cardTasks = rawCards.map(async (card) => { | ||
return processCard(card, rawCards); | ||
}); | ||
const cards = await Promise.all(cardTasks); | ||
|
||
return { | ||
locale, | ||
cards, | ||
}; | ||
}); | ||
|
||
const assets = await Promise.all(assetsTasks); | ||
const assetsByLocale = assets.reduce((assets, asset) => { | ||
assets[asset.locale] = asset; | ||
return assets; | ||
}, {}); | ||
|
||
return { | ||
props: { | ||
assetsByLocale, | ||
}, | ||
}; | ||
}; | ||
|
||
const Admin = ({ assetsByLocale }) => { | ||
const Cms = DecapCms(assetsByLocale); | ||
return ( | ||
<> | ||
<Head> | ||
<title>Content Manager</title> | ||
</Head> | ||
<Script | ||
id="netlify-identity-widget" | ||
src="https://identity.netlify.com/v1/netlify-identity-widget.js" | ||
/> | ||
<Cms /> | ||
</> | ||
); | ||
}; | ||
|
||
export default Admin; | ||
|
||
Admin.getLayout = (page) => page; |
Oops, something went wrong.