Skip to content

Commit

Permalink
refactor: fix the SSR/CSR mismatch (#146)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
HsiangNianian authored Sep 13, 2024
1 parent 3c51e26 commit 76faaca
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- main
workflow_dispatch:
# Review gh actions docs if you want to further define triggers, paths, etc
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on

Expand All @@ -19,6 +20,6 @@ jobs:
- name: Install pnpm
run: npm install -g pnpm@8
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
run: pnpm i --no-frozen-lockfile --unsafe-perm --ignore-scripts
- name: Test build website
run: pnpm build
13 changes: 13 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ const config = {
},
}),
plugins: [
customPostCssPlugin,
"docusaurus-plugin-sass",
async function TailwindCSSPlugin(context, options) {
return {
Expand All @@ -225,4 +226,16 @@ const config = {
],
};

/** @return {import('@docusaurus/types').Plugin} */
function customPostCssPlugin() {
return {
name: "custom-postcss",
configurePostCss(options) {
// Append new PostCSS plugins here.
options.plugins.push(require("postcss-preset-env")); // allow newest CSS syntax
return options;
}
};
}

module.exports = config;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"documate:upload": "documate upload"
},
"dependencies": {
"postcss-preset-env": "^10.0.3",
"@crowdin/cli": "3",
"@crowdin/crowdin-api-client": "^1.23.4",
"@docusaurus/core": "3.4.0",
Expand Down
20 changes: 7 additions & 13 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Link from "@docusaurus/Link";
import { useColorMode } from "@docusaurus/theme-common";
// import useBaseUrl from '@docusaurus/useBaseUrl';
import ThemedImage from '@theme/ThemedImage';
import Translate from "@docusaurus/Translate";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import Layout from "@theme/Layout";
Expand Down Expand Up @@ -100,8 +101,6 @@ function HomepageHeader() {


const HomeBaseContent = () => {
const { colorMode } = useColorMode();

const mainContent = React.useMemo(() => {
return (
<main className="mb-20 my-10 max-w-7xl mx-auto w-full px-4 sm:px-6 lg:px-8max-w-6xl">
Expand All @@ -112,21 +111,16 @@ const HomeBaseContent = () => {
);
}, []);

if (colorMode === "dark") {
return (
<>
<StarrySky />
{mainContent}
</>
);
} else {
return (
<>
<AuroraBackground />
<ThemedImage sources={{
light: <StarrySky />,
dark: <AuroraBackground />,
}}
/>
{mainContent}
</>
);
}
};


Expand Down

0 comments on commit 76faaca

Please sign in to comment.