aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-10-23 00:46:07 +0300
committereug-vs <eugene@eug-vs.xyz>2022-10-23 00:47:52 +0300
commit21a182985b7fa0c55691d5595b807dfcce2f4631 (patch)
treece2fc326a11fc15dea19963cb6866b0ab5429a8a
parent4ec99c86f7a55622fcad588ae61b6cee7d02ff9c (diff)
downloadbenzin-next-21a182985b7fa0c55691d5595b807dfcce2f4631.tar.gz
refactor: benzinConfig -> config
-rw-r--r--src/Emoji.tsx4
-rw-r--r--src/Image.tsx4
-rw-r--r--src/benzinConfig.ts14
-rw-r--r--src/config.ts16
-rw-r--r--src/lib/types.ts11
-rw-r--r--src/pages/[...path].tsx6
-rw-r--r--src/pages/_app.tsx6
-rw-r--r--src/pages/_document.tsx4
8 files changed, 35 insertions, 30 deletions
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<Props> = ({ children }) => {
const src = children[0];
return (
<Image
- src={`${benzinConfig.CDN}/public/emoji/${src}`}
+ src={`${config.CDN}${config.paths.emojiRoot}/${src}`}
width={16}
alt={`${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<Props> = ({ 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) => {
<Head>
<title>{benzinConfig.title}</title>
<meta name="description" content="TODO" />
- <link rel="icon" href={`${benzinConfig.CDN}${benzinConfig.faviconPath}`}/>
+ <link rel="icon" href={`${benzinConfig.CDN}${benzinConfig.paths.favicon}`}/>
</Head>
<main>
<ReactMarkdown
diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx
index 715179b..d295175 100644
--- a/src/pages/_app.tsx
+++ b/src/pages/_app.tsx
@@ -1,14 +1,14 @@
import '../styles/globals.css';
import type { AppProps } from 'next/app';
import Image from 'next/future/image';
-import benzinConfig from '../benzinConfig';
+import config from '../config';
function MyApp({ Component, pageProps }: AppProps) {
return (
<>
<a href="/" style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', textDecoration: 'none', marginBottom: '12px' }}>
- <Image src={benzinConfig.CDN + benzinConfig.logoPath} width={128} height={128} alt="logo" />
- <h1>{benzinConfig.title}</h1>
+ <Image src={config.CDN + config.paths.logo} width={128} height={128} alt="logo" />
+ <h1>{config.title}</h1>
</a>
<Component {...pageProps} />
</>
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 (
<Html>
<Head>
- <link rel="stylesheet" href={`${benzinConfig.CDN}${benzinConfig.cssPath}`} type="text/css" />
+ <link rel="stylesheet" href={`${config.CDN}${config.paths.css}`} type="text/css" />
</Head>
<body>
<Main />