From 21a182985b7fa0c55691d5595b807dfcce2f4631 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 23 Oct 2022 00:46:07 +0300 Subject: refactor: benzinConfig -> config --- src/Emoji.tsx | 4 ++-- src/Image.tsx | 4 ++-- src/benzinConfig.ts | 14 -------------- src/config.ts | 16 ++++++++++++++++ src/lib/types.ts | 11 +++++++---- src/pages/[...path].tsx | 6 +++--- src/pages/_app.tsx | 6 +++--- src/pages/_document.tsx | 4 ++-- 8 files changed, 35 insertions(+), 30 deletions(-) delete mode 100644 src/benzinConfig.ts create mode 100644 src/config.ts (limited to 'src') diff --git a/src/Emoji.tsx b/src/Emoji.tsx index df5108d..275670e 100644 --- a/src/Emoji.tsx +++ b/src/Emoji.tsx @@ -1,6 +1,6 @@ import { FC } from 'react'; import Image from 'next/future/image'; -import benzinConfig from './benzinConfig'; +import config from './config'; interface Props { children: string[]; @@ -10,7 +10,7 @@ const Emoji: FC = ({ children }) => { const src = children[0]; return ( {`${src}-emoji`} diff --git a/src/Image.tsx b/src/Image.tsx index 37e55ba..0989451 100644 --- a/src/Image.tsx +++ b/src/Image.tsx @@ -1,12 +1,12 @@ import ImageBase from 'next/future/image'; import { FC } from 'react'; -import benzinConfig from './benzinConfig'; +import config from './config'; type Props = Record<'src' | 'alt', string>; const localizeSrc = (src: string) => { if (src.startsWith('http')) return src; - return benzinConfig.CDN + src; + return config.CDN + src; } const Image: FC = ({ src, ...props }) => { diff --git a/src/benzinConfig.ts b/src/benzinConfig.ts deleted file mode 100644 index 3f355ed..0000000 --- a/src/benzinConfig.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { BenzinConfig } from './lib/types'; -import nginxAdapter from './lib/nginxAdapter'; - -const benzinConfig: BenzinConfig = { - title: `Eugene's Space`, - CDN: 'https://git.eug-vs.xyz/eug-vs/eug-vs-xyz/plain/src', - adapter: nginxAdapter, - faviconPath: '/public/icon-64.png', - logoPath: '/public/eug-vs.png', - emojiRootPath: '/emoji', - cssPath: '/public/style.css?h=benzin-next-cdn' -}; - -export default benzinConfig; diff --git a/src/config.ts b/src/config.ts new file mode 100644 index 0000000..544d15c --- /dev/null +++ b/src/config.ts @@ -0,0 +1,16 @@ +import { BenzinConfig } from './lib/types'; +import nginxAdapter from './lib/nginxAdapter'; + +const config: BenzinConfig = { + title: `Eugene's Space`, + CDN: 'https://git.eug-vs.xyz/eug-vs/eug-vs-xyz/plain/src', + adapter: nginxAdapter, + paths: { + favicon: '/public/icon-64.png', + logo: '/public/eug-vs.png', + emojiRoot: '/public/emoji', + css: '/public/style.css?h=benzin-next-cdn', + }, +}; + +export default config; diff --git a/src/lib/types.ts b/src/lib/types.ts index e6bb22a..ed2566f 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -11,8 +11,11 @@ export interface BenzinConfig { CDN: string; adapter: Adapter; title: string; - faviconPath: string; - logoPath: string; - emojiRootPath: string; - cssPath: string; + + paths: { + favicon: string; + logo: string; + emojiRoot: string; + css: string; + } } diff --git a/src/pages/[...path].tsx b/src/pages/[...path].tsx index 19dc42d..9f55cf8 100644 --- a/src/pages/[...path].tsx +++ b/src/pages/[...path].tsx @@ -6,7 +6,7 @@ import Emoji from '../Emoji'; import Image from '../Image'; import emojiPlugin from '../emojiPlugin'; import remarkGemoji from 'remark-gemoji'; -import benzinConfig from '../benzinConfig'; +import benzinConfig from '../config'; import Code from '../Code'; const transformLinkUri = (uri: string): string => { @@ -30,7 +30,7 @@ export const getStaticProps = async (context: GetStaticPropsContext) => { ); const markdownSource = await benzinConfig.adapter.getMarkdownSource(benzinConfig.CDN, path); - const emojiFileNames = await benzinConfig.adapter.getEmojiFileNames(benzinConfig.CDN, benzinConfig.emojiRootPath); + const emojiFileNames = await benzinConfig.adapter.getEmojiFileNames(benzinConfig.CDN, benzinConfig.paths.emojiRoot); return { props: { @@ -56,7 +56,7 @@ const Page: NextPage = ({ markdownSource, emojiFileNames }: any) => { {benzinConfig.title} - +
- logo -

{benzinConfig.title}

+ logo +

{config.title}

diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index c783ad4..770d9c4 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -1,11 +1,11 @@ import { Html, Head, Main, NextScript } from 'next/document' -import benzinConfig from '../benzinConfig' +import config from '../config' export default function Document() { return ( - +
-- cgit v1.2.3