-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: refactor packages to work with both ssr and csr
- Loading branch information
Showing
49 changed files
with
3,827 additions
and
974 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
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 |
---|---|---|
@@ -1,41 +1,28 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": [ | ||
"dom", | ||
"dom.iterable", | ||
"esnext" | ||
], | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"module": "nodenext", | ||
"moduleResolution": "nodenext", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "preserve", | ||
"incremental": true, | ||
"paths": { | ||
"@/*": [ | ||
"./src/*" | ||
] | ||
"@/*": ["./src/*"] | ||
}, | ||
"plugins": [ | ||
{ | ||
"name": "next" | ||
} | ||
] | ||
}, | ||
"include": [ | ||
"next-env.d.ts", | ||
"**/*.ts", | ||
"**/*.tsx", | ||
"build/types/**/*.ts" | ||
], | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "build/types/**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
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,10 @@ | ||
import * as OptionApi from '@/src/apis/option'; | ||
|
||
export async function getAboutMarkdown() { | ||
const response = await OptionApi.getAbout(); | ||
if (response.isSuccessful) { | ||
return response.data.about; | ||
} else { | ||
throw new Error(response.message); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,18 +1,15 @@ | ||
'use client'; | ||
import type {Metadata} from 'next'; | ||
|
||
import {AntdWrapper} from '@/src/components/AntdWrapper'; | ||
import {useAbout} from '@/src/hooks/useAbout'; | ||
import {getAboutMarkdown} from '@/src/app/about/AboutViewModel'; | ||
|
||
import {AboutView} from './View'; | ||
|
||
export function About() { | ||
const {loading: aboutIsLoading, about} = useAbout(); | ||
export const metadata: Metadata = { | ||
title: '关于 - Soulike 的博客', | ||
}; | ||
|
||
document.title = '关于 - Soulike 的博客'; | ||
export async function About() { | ||
const aboutMarkdown = await getAboutMarkdown(); | ||
|
||
return ( | ||
<AntdWrapper> | ||
<AboutView aboutMarkdown={about ?? ''} loading={aboutIsLoading} /> | ||
</AntdWrapper> | ||
); | ||
return <AboutView aboutMarkdown={aboutMarkdown} />; | ||
} |
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 |
---|---|---|
@@ -1,30 +1,21 @@ | ||
import {Markdown} from '@website/react-components'; | ||
import {Skeleton} from 'antd'; | ||
import '@website/react-components/style.css'; | ||
|
||
import {Markdown} from '@website/react-components/ssr'; | ||
|
||
import Style from './Style.module.scss'; | ||
|
||
interface Props { | ||
loading: boolean; | ||
aboutMarkdown: string; | ||
} | ||
|
||
export function AboutView(props: Props) { | ||
const {loading, aboutMarkdown} = props; | ||
const {aboutMarkdown} = props; | ||
return ( | ||
<div className={Style.About}> | ||
<Skeleton | ||
loading={loading} | ||
active={true} | ||
title={true} | ||
paragraph={{ | ||
rows: 20, | ||
}} | ||
> | ||
<header className={Style.header}> | ||
<h1 className={Style.title}>关于</h1> | ||
</header> | ||
<Markdown>{aboutMarkdown}</Markdown> | ||
</Skeleton> | ||
<header className={Style.header}> | ||
<h1 className={Style.title}>关于</h1> | ||
</header> | ||
<Markdown>{aboutMarkdown}</Markdown> | ||
</div> | ||
); | ||
} |
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
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 |
---|---|---|
@@ -1,5 +1 @@ | ||
import dynamic from 'next/dynamic'; | ||
|
||
const promise = import('./Container').then(({ArticleList}) => ArticleList); | ||
|
||
export const ArticleList = dynamic(async () => await promise, {ssr: false}); | ||
export * from './Container'; |
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
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,23 @@ | ||
import { | ||
convertDOMToString, | ||
convertHTMLStringToDOM, | ||
yieldMainThread, | ||
} from '@website/utils/csr'; | ||
|
||
import {hljs} from '../hljs'; | ||
|
||
export async function highlightAll(html: string): Promise<string> { | ||
const dom = convertHTMLStringToDOM(html); | ||
|
||
const preBlocks = Array.from(dom.querySelectorAll('pre')); | ||
await Promise.all( | ||
preBlocks.map(async (pre) => { | ||
const codeBlocks = pre.querySelectorAll('code'); | ||
codeBlocks.forEach((block) => { | ||
hljs.highlightElement(block); | ||
}); | ||
await yieldMainThread(); | ||
}), | ||
); | ||
return convertDOMToString(dom); | ||
} |
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,76 @@ | ||
import './style.css'; | ||
|
||
import hljs from 'highlight.js/lib/core'; | ||
import applescript from 'highlight.js/lib/languages/applescript'; | ||
import bash from 'highlight.js/lib/languages/bash'; | ||
import bnf from 'highlight.js/lib/languages/bnf'; | ||
import c from 'highlight.js/lib/languages/c'; | ||
import cmake from 'highlight.js/lib/languages/cmake'; | ||
import cpp from 'highlight.js/lib/languages/cpp'; | ||
import csharp from 'highlight.js/lib/languages/csharp'; | ||
import css from 'highlight.js/lib/languages/css'; | ||
import diff from 'highlight.js/lib/languages/diff'; | ||
import dns from 'highlight.js/lib/languages/dns'; | ||
import dockerfile from 'highlight.js/lib/languages/dockerfile'; | ||
import go from 'highlight.js/lib/languages/go'; | ||
import gradle from 'highlight.js/lib/languages/gradle'; | ||
import http from 'highlight.js/lib/languages/http'; | ||
import ini from 'highlight.js/lib/languages/ini'; | ||
import java from 'highlight.js/lib/languages/java'; | ||
import javascript from 'highlight.js/lib/languages/javascript'; | ||
import json from 'highlight.js/lib/languages/json'; | ||
import latex from 'highlight.js/lib/languages/latex'; | ||
import less from 'highlight.js/lib/languages/less'; | ||
import llvm from 'highlight.js/lib/languages/llvm'; | ||
import makefile from 'highlight.js/lib/languages/makefile'; | ||
import markdown from 'highlight.js/lib/languages/markdown'; | ||
import matlab from 'highlight.js/lib/languages/matlab'; | ||
import nginx from 'highlight.js/lib/languages/nginx'; | ||
import pgsql from 'highlight.js/lib/languages/pgsql'; | ||
import plaintext from 'highlight.js/lib/languages/plaintext'; | ||
import powershell from 'highlight.js/lib/languages/powershell'; | ||
import python from 'highlight.js/lib/languages/python'; | ||
import scss from 'highlight.js/lib/languages/scss'; | ||
import shell from 'highlight.js/lib/languages/shell'; | ||
import sql from 'highlight.js/lib/languages/sql'; | ||
import typescript from 'highlight.js/lib/languages/typescript'; | ||
import xml from 'highlight.js/lib/languages/xml'; | ||
import yaml from 'highlight.js/lib/languages/yaml'; | ||
|
||
hljs.registerLanguage('plaintext', plaintext); | ||
hljs.registerLanguage('makefile', makefile); | ||
hljs.registerLanguage('markdown', markdown); | ||
hljs.registerLanguage('cmake', cmake); | ||
hljs.registerLanguage('gradle', gradle); | ||
hljs.registerLanguage('llvm', llvm); | ||
hljs.registerLanguage('cpp', cpp); | ||
hljs.registerLanguage('c', c); | ||
hljs.registerLanguage('csharp', csharp); | ||
hljs.registerLanguage('java', java); | ||
hljs.registerLanguage('yaml', yaml); | ||
hljs.registerLanguage('xml', xml); | ||
hljs.registerLanguage('sql', sql); | ||
hljs.registerLanguage('pgsql', pgsql); | ||
hljs.registerLanguage('http', http); | ||
hljs.registerLanguage('json', json); | ||
hljs.registerLanguage('css', css); | ||
hljs.registerLanguage('scss', scss); | ||
hljs.registerLanguage('less', less); | ||
hljs.registerLanguage('applescript', applescript); | ||
hljs.registerLanguage('javascript', javascript); | ||
hljs.registerLanguage('typescript', typescript); | ||
hljs.registerLanguage('python', python); | ||
hljs.registerLanguage('go', go); | ||
hljs.registerLanguage('bash', bash); | ||
hljs.registerLanguage('shell', shell); | ||
hljs.registerLanguage('powershell', powershell); | ||
hljs.registerLanguage('ini', ini); | ||
hljs.registerLanguage('nginx', nginx); | ||
hljs.registerLanguage('dns', dns); | ||
hljs.registerLanguage('diff', diff); | ||
hljs.registerLanguage('dockerfile', dockerfile); | ||
hljs.registerLanguage('bnf', bnf); | ||
hljs.registerLanguage('latex', latex); | ||
hljs.registerLanguage('matlab', matlab); | ||
|
||
export {hljs}; |
Oops, something went wrong.