Skip to content

Commit 76faaca

Browse files
refactor: fix the SSR/CSR mismatch (#146)
* chore(ci): add manually active test deploy event in test-deploy.yml * chore: add --unsafe-perm --ignore-scripts hook to safe the project * chore(deps): add "postcss-preset-env": "^10.0.3" * feat: update configuring of compilation * fix: ensure colorMode be used inline ColorModeProvider * fix: ensure colorMode be used inline ColorModeProvider 2 * revert: recover src/pages/index.tsx #142 * fix: multiple reference problems * revert: due to 'revert: recover src/pages/index.tsx #142' 860949b * chore(index): supports themed images
1 parent 3c51e26 commit 76faaca

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

.github/workflows/test-deploy.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
branches:
66
- main
7+
workflow_dispatch:
78
# Review gh actions docs if you want to further define triggers, paths, etc
89
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
910

@@ -19,6 +20,6 @@ jobs:
1920
- name: Install pnpm
2021
run: npm install -g pnpm@8
2122
- name: Install dependencies
22-
run: pnpm install --no-frozen-lockfile
23+
run: pnpm i --no-frozen-lockfile --unsafe-perm --ignore-scripts
2324
- name: Test build website
2425
run: pnpm build

docusaurus.config.js

+13
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ const config = {
210210
},
211211
}),
212212
plugins: [
213+
customPostCssPlugin,
213214
"docusaurus-plugin-sass",
214215
async function TailwindCSSPlugin(context, options) {
215216
return {
@@ -225,4 +226,16 @@ const config = {
225226
],
226227
};
227228

229+
/** @return {import('@docusaurus/types').Plugin} */
230+
function customPostCssPlugin() {
231+
return {
232+
name: "custom-postcss",
233+
configurePostCss(options) {
234+
// Append new PostCSS plugins here.
235+
options.plugins.push(require("postcss-preset-env")); // allow newest CSS syntax
236+
return options;
237+
}
238+
};
239+
}
240+
228241
module.exports = config;

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"documate:upload": "documate upload"
2424
},
2525
"dependencies": {
26+
"postcss-preset-env": "^10.0.3",
2627
"@crowdin/cli": "3",
2728
"@crowdin/crowdin-api-client": "^1.23.4",
2829
"@docusaurus/core": "3.4.0",

src/pages/index.tsx

+7-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Link from "@docusaurus/Link";
2-
import { useColorMode } from "@docusaurus/theme-common";
2+
// import useBaseUrl from '@docusaurus/useBaseUrl';
3+
import ThemedImage from '@theme/ThemedImage';
34
import Translate from "@docusaurus/Translate";
45
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
56
import Layout from "@theme/Layout";
@@ -100,8 +101,6 @@ function HomepageHeader() {
100101

101102

102103
const HomeBaseContent = () => {
103-
const { colorMode } = useColorMode();
104-
105104
const mainContent = React.useMemo(() => {
106105
return (
107106
<main className="mb-20 my-10 max-w-7xl mx-auto w-full px-4 sm:px-6 lg:px-8max-w-6xl">
@@ -112,21 +111,16 @@ const HomeBaseContent = () => {
112111
);
113112
}, []);
114113

115-
if (colorMode === "dark") {
116-
return (
117-
<>
118-
<StarrySky />
119-
{mainContent}
120-
</>
121-
);
122-
} else {
123114
return (
124115
<>
125-
<AuroraBackground />
116+
<ThemedImage sources={{
117+
light: <StarrySky />,
118+
dark: <AuroraBackground />,
119+
}}
120+
/>
126121
{mainContent}
127122
</>
128123
);
129-
}
130124
};
131125

132126

0 commit comments

Comments
 (0)