diff --git "a/homepage/_cards/en/\345\205\254\345\213\231\345\223\241.md" "b/homepage/_cards/en/\345\205\254\345\213\231\345\223\241.md" index c431f386..4e72958b 100644 --- "a/homepage/_cards/en/\345\205\254\345\213\231\345\223\241.md" +++ "b/homepage/_cards/en/\345\205\254\345\213\231\345\223\241.md" @@ -7,4 +7,3 @@ type: job tags: - civil servants --- -Public Servant \ No newline at end of file diff --git "a/homepage/_cards/en/\345\267\245\347\250\213\345\270\253.md" "b/homepage/_cards/en/\345\267\245\347\250\213\345\270\253.md" index b634c857..b980f82b 100644 --- "a/homepage/_cards/en/\345\267\245\347\250\213\345\270\253.md" +++ "b/homepage/_cards/en/\345\267\245\347\250\213\345\270\253.md" @@ -7,4 +7,3 @@ type: job tags: - engineer --- -Engineer \ No newline at end of file diff --git "a/homepage/_cards/en/\346\226\207\345\255\227\345\267\245\344\275\234\350\200\205.md" "b/homepage/_cards/en/\346\226\207\345\255\227\345\267\245\344\275\234\350\200\205.md" index 37b98826..eb377857 100644 --- "a/homepage/_cards/en/\346\226\207\345\255\227\345\267\245\344\275\234\350\200\205.md" +++ "b/homepage/_cards/en/\346\226\207\345\255\227\345\267\245\344\275\234\350\200\205.md" @@ -7,4 +7,3 @@ type: job tags: - writer --- -Copywriter \ No newline at end of file diff --git "a/homepage/_cards/en/\346\263\225\345\213\231\344\272\272\345\223\241.md" "b/homepage/_cards/en/\346\263\225\345\213\231\344\272\272\345\223\241.md" index 4124167c..abaeed6c 100644 --- "a/homepage/_cards/en/\346\263\225\345\213\231\344\272\272\345\223\241.md" +++ "b/homepage/_cards/en/\346\263\225\345\213\231\344\272\272\345\223\241.md" @@ -7,4 +7,3 @@ type: job tags: - legal --- -Legal Personnel \ No newline at end of file diff --git "a/homepage/_cards/en/\347\276\216\350\241\223\350\250\255\350\250\210.md" "b/homepage/_cards/en/\347\276\216\350\241\223\350\250\255\350\250\210.md" index 66b1ce24..9ed7c30f 100644 --- "a/homepage/_cards/en/\347\276\216\350\241\223\350\250\255\350\250\210.md" +++ "b/homepage/_cards/en/\347\276\216\350\241\223\350\250\255\350\250\210.md" @@ -7,4 +7,3 @@ type: job tags: - designer --- -AD \ No newline at end of file diff --git "a/homepage/_cards/en/\350\241\214\351\212\267\345\205\254\351\227\234.md" "b/homepage/_cards/en/\350\241\214\351\212\267\345\205\254\351\227\234.md" index ba572d73..963d2eb7 100644 --- "a/homepage/_cards/en/\350\241\214\351\212\267\345\205\254\351\227\234.md" +++ "b/homepage/_cards/en/\350\241\214\351\212\267\345\205\254\351\227\234.md" @@ -7,4 +7,3 @@ type: job tags: - marketing --- -Marketing PR \ No newline at end of file diff --git "a/homepage/_cards/en/\350\255\260\351\241\214\345\267\245\344\275\234\350\200\205.md" "b/homepage/_cards/en/\350\255\260\351\241\214\345\267\245\344\275\234\350\200\205.md" index 00e8c227..46427405 100644 --- "a/homepage/_cards/en/\350\255\260\351\241\214\345\267\245\344\275\234\350\200\205.md" +++ "b/homepage/_cards/en/\350\255\260\351\241\214\345\267\245\344\275\234\350\200\205.md" @@ -7,4 +7,3 @@ type: job tags: - advocator --- -Advocator \ No newline at end of file diff --git "a/homepage/_cards/zh-tw/\345\205\254\345\213\231\345\223\241.md" "b/homepage/_cards/zh-tw/\345\205\254\345\213\231\345\223\241.md" index 9e280276..78206083 100644 --- "a/homepage/_cards/zh-tw/\345\205\254\345\213\231\345\223\241.md" +++ "b/homepage/_cards/zh-tw/\345\205\254\345\213\231\345\223\241.md" @@ -7,4 +7,3 @@ type: job tags: - civil servants --- -公務 \ No newline at end of file diff --git "a/homepage/_cards/zh-tw/\345\267\245\347\250\213\345\270\253.md" "b/homepage/_cards/zh-tw/\345\267\245\347\250\213\345\270\253.md" index 74f9a4d4..3e8bf916 100644 --- "a/homepage/_cards/zh-tw/\345\267\245\347\250\213\345\270\253.md" +++ "b/homepage/_cards/zh-tw/\345\267\245\347\250\213\345\270\253.md" @@ -7,4 +7,3 @@ type: job tags: - engineer --- -工程 \ No newline at end of file diff --git "a/homepage/_cards/zh-tw/\346\226\207\345\255\227\345\267\245\344\275\234\350\200\205.md" "b/homepage/_cards/zh-tw/\346\226\207\345\255\227\345\267\245\344\275\234\350\200\205.md" index 5ce291d9..d23011db 100644 --- "a/homepage/_cards/zh-tw/\346\226\207\345\255\227\345\267\245\344\275\234\350\200\205.md" +++ "b/homepage/_cards/zh-tw/\346\226\207\345\255\227\345\267\245\344\275\234\350\200\205.md" @@ -7,4 +7,3 @@ type: job tags: - writer --- -文字 \ No newline at end of file diff --git "a/homepage/_cards/zh-tw/\346\263\225\345\213\231\344\272\272\345\223\241.md" "b/homepage/_cards/zh-tw/\346\263\225\345\213\231\344\272\272\345\223\241.md" index a7ab69ba..55068933 100644 --- "a/homepage/_cards/zh-tw/\346\263\225\345\213\231\344\272\272\345\223\241.md" +++ "b/homepage/_cards/zh-tw/\346\263\225\345\213\231\344\272\272\345\223\241.md" @@ -7,4 +7,3 @@ type: job tags: - legal --- -法務 \ No newline at end of file diff --git "a/homepage/_cards/zh-tw/\347\276\216\350\241\223\350\250\255\350\250\210.md" "b/homepage/_cards/zh-tw/\347\276\216\350\241\223\350\250\255\350\250\210.md" index d6b2d24c..5752dc14 100644 --- "a/homepage/_cards/zh-tw/\347\276\216\350\241\223\350\250\255\350\250\210.md" +++ "b/homepage/_cards/zh-tw/\347\276\216\350\241\223\350\250\255\350\250\210.md" @@ -7,4 +7,3 @@ type: job tags: - designer --- -美術 \ No newline at end of file diff --git "a/homepage/_cards/zh-tw/\350\241\214\351\212\267\345\205\254\351\227\234.md" "b/homepage/_cards/zh-tw/\350\241\214\351\212\267\345\205\254\351\227\234.md" index ca5184b4..2fe202f1 100644 --- "a/homepage/_cards/zh-tw/\350\241\214\351\212\267\345\205\254\351\227\234.md" +++ "b/homepage/_cards/zh-tw/\350\241\214\351\212\267\345\205\254\351\227\234.md" @@ -7,4 +7,3 @@ type: job tags: - marketing --- -行銷 \ No newline at end of file diff --git "a/homepage/_cards/zh-tw/\350\255\260\351\241\214\345\267\245\344\275\234\350\200\205.md" "b/homepage/_cards/zh-tw/\350\255\260\351\241\214\345\267\245\344\275\234\350\200\205.md" index d07f994a..bf5105d7 100644 --- "a/homepage/_cards/zh-tw/\350\255\260\351\241\214\345\267\245\344\275\234\350\200\205.md" +++ "b/homepage/_cards/zh-tw/\350\255\260\351\241\214\345\267\245\344\275\234\350\200\205.md" @@ -7,4 +7,3 @@ type: job tags: - advocator --- -議題 \ No newline at end of file diff --git a/homepage/_pages/zh-tw/index.md b/homepage/_pages/zh-tw/index.md index 06f011d4..37b85c93 100644 --- a/homepage/_pages/zh-tw/index.md +++ b/homepage/_pages/zh-tw/index.md @@ -44,22 +44,13 @@ layout_list: title: 桌遊用途 columns: - title: 教學教材 - text: |- - ### - - 無論大學、高中課程,教學簡報配合桌遊,輕鬆認識開源觀念,提升公民行動力! + text: 無論大學、高中課程,教學簡報配合桌遊,輕鬆認識開源觀念,提升公民行動力! image: /images/uploads/pxl_20230508_052023298.jpg - title: 社群推坑 - text: |- - ### - - 已是開源老手、社群活躍成員的你,想要不費吹灰之力吸收新血?揪團玩就對了! + text: 已是開源老手、社群活躍成員的你,想要不費吹灰之力吸收新血?揪團玩就對了! image: /images/uploads/pxl_20230730_051310179.jpeg - title: 破冰團康 - text: |- - ### - - 社團活動怎麼帶?利用星手村桌遊,輕鬆達到破冰與理念推廣。學弟學妹揪起來! + text: 社團活動怎麼帶?利用星手村桌遊,輕鬆達到破冰與理念推廣。學弟學妹揪起來! image: /images/uploads/img_3763.jpeg - type: layout_section title: 桌遊背後的故事 diff --git a/homepage/public/css/style.css b/homepage/public/css/style.css index eb285024..91cc2dc5 100644 --- a/homepage/public/css/style.css +++ b/homepage/public/css/style.css @@ -963,9 +963,6 @@ code { } } @media only screen and (min-width: 768px) and (max-width: 991px) { - .avatar-tablet { - transform: translate(-13%); - } } @media only screen and (max-width: 767px) { .container { diff --git a/homepage/src/CMS/DecapCms.jsx b/homepage/src/CMS/DecapCms.jsx new file mode 100644 index 00000000..cd723b61 --- /dev/null +++ b/homepage/src/CMS/DecapCms.jsx @@ -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) => ( + + ); + 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/bootstrap@4.6.2/dist/css/bootstrap.min.css', + ); + cms.registerPreviewStyle( + 'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.4/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: () =>

Loading...

}, + ); + +export default DecapCms; diff --git a/homepage/src/pages/admin/config.json b/homepage/src/CMS/config.json similarity index 98% rename from homepage/src/pages/admin/config.json rename to homepage/src/CMS/config.json index 622bf4fa..e4dc729b 100644 --- a/homepage/src/pages/admin/config.json +++ b/homepage/src/CMS/config.json @@ -36,7 +36,11 @@ }, { "label": "Name", "name": "name", "widget": "string", "i18n": true }, { - "label": "Page order", "name": "page_order", "widget": "number", "value_type": "int", "i18n": "duplicate" + "label": "Page order", + "name": "page_order", + "widget": "number", + "value_type": "int", + "i18n": "duplicate" }, { "label": "Layout & Content", @@ -294,6 +298,7 @@ "label": "Content", "name": "body", "widget": "markdown", + "required": false, "i18n": true } ] diff --git a/homepage/src/CMS/preview/CardPreview.jsx b/homepage/src/CMS/preview/CardPreview.jsx new file mode 100644 index 00000000..2c3f418f --- /dev/null +++ b/homepage/src/CMS/preview/CardPreview.jsx @@ -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 ; +}; + +export default CardPreview; diff --git a/homepage/src/CMS/preview/FooterPreview.jsx b/homepage/src/CMS/preview/FooterPreview.jsx new file mode 100644 index 00000000..b798d968 --- /dev/null +++ b/homepage/src/CMS/preview/FooterPreview.jsx @@ -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 ; +}; + +export default FooterPreview; diff --git a/homepage/src/CMS/preview/PagePreview.jsx b/homepage/src/CMS/preview/PagePreview.jsx new file mode 100644 index 00000000..45d3c313 --- /dev/null +++ b/homepage/src/CMS/preview/PagePreview.jsx @@ -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
{sections}
; +}; + +export default PagePreview; diff --git a/homepage/src/components/cards/defaultCard.jsx b/homepage/src/components/cards/defaultCard.jsx index f31cd041..3c0c357b 100644 --- a/homepage/src/components/cards/defaultCard.jsx +++ b/homepage/src/components/cards/defaultCard.jsx @@ -15,7 +15,7 @@ const DefaultCard = ({ card }) => (

{card.data.title}

diff --git a/homepage/src/pages/admin.jsx b/homepage/src/pages/admin.jsx new file mode 100644 index 00000000..87f19150 --- /dev/null +++ b/homepage/src/pages/admin.jsx @@ -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 ( + <> + + Content Manager + +