-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8ff262
commit 69f5363
Showing
40 changed files
with
563 additions
and
279 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
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,20 @@ | ||
import { memo } from 'react'; | ||
|
||
const MicrosoftClarity = memo<{ projectId: string }>(({ projectId }) => { | ||
return ( | ||
<script | ||
dangerouslySetInnerHTML={{ | ||
__html: ` | ||
(function(c,l,a,r,i,t,y){ | ||
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; | ||
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; | ||
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); | ||
})(window, document, "clarity", "script", "${projectId}"); | ||
`, | ||
}} | ||
id="microsoft-clarity-init" | ||
/> | ||
); | ||
}); | ||
|
||
export default MicrosoftClarity; |
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,24 @@ | ||
import { memo } from 'react'; | ||
|
||
const GoogleAnalytics = memo<{ measurementId: string }>(({ measurementId }) => { | ||
return ( | ||
<> | ||
<script async src={`https://www.googletagmanager.com/gtag/js?id=${measurementId}`} /> | ||
<script | ||
dangerouslySetInnerHTML={{ | ||
__html: ` | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag(){dataLayer.push(arguments);} | ||
gtag('js', new Date()); | ||
gtag('config', '${measurementId}'); | ||
`, | ||
}} | ||
id="google-analytics" | ||
type="text/javascript" | ||
/> | ||
</> | ||
); | ||
}); | ||
|
||
export default GoogleAnalytics; |
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,9 @@ | ||
import { memo } from 'react'; | ||
|
||
const PlausibleAnalytics = memo<{ domain: string; scriptBaseUrl: string }>( | ||
({ domain, scriptBaseUrl }) => ( | ||
<script data-domain={domain} defer src={`${scriptBaseUrl}/js/script.js`} /> | ||
), | ||
); | ||
|
||
export default PlausibleAnalytics; |
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,25 @@ | ||
import { siteSelectors, useSiteStore } from '@/store'; | ||
|
||
import ClarityAnalytics from './Clarity'; | ||
import GoogleAnalytics from './GoogleAnalytics'; | ||
import Plausible from './Plausible'; | ||
|
||
const Analytics = () => { | ||
const analytics = useSiteStore(siteSelectors.analytics); | ||
return ( | ||
<> | ||
{analytics?.googleAnalytics && ( | ||
<GoogleAnalytics measurementId={analytics.googleAnalytics.measurementId} /> | ||
)} | ||
{analytics?.clarity && <ClarityAnalytics projectId={analytics.clarity.projectId} />} | ||
{analytics?.plausible && ( | ||
<Plausible | ||
domain={analytics.plausible.domain} | ||
scriptBaseUrl={analytics.plausible.scriptBaseUrl} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default Analytics; |
This file was deleted.
Oops, something went wrong.
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 { createGlobalStyle } from 'antd-style'; | ||
|
||
const GlobalStyle = createGlobalStyle` | ||
#root { | ||
min-height: 100vh; | ||
} | ||
#nprogress { | ||
.bar { | ||
background: ${({ theme }) => theme.colorText}; | ||
} | ||
.peg { | ||
display: none !important; | ||
} | ||
.spinner { | ||
display: none; | ||
} | ||
} | ||
`; | ||
|
||
export default GlobalStyle; |
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,19 +1,54 @@ | ||
import { useLocation } from '@@/exports'; | ||
import { ThemeProvider } from '@lobehub/ui'; | ||
import { useOutlet } from 'dumi'; | ||
import { | ||
useLocale, | ||
useNavData, | ||
useOutlet, | ||
useRouteMeta, | ||
useSidebarData, | ||
useSiteData, | ||
useTabMeta, | ||
} from 'dumi'; | ||
import isEqual from 'fast-deep-equal'; | ||
import { memo } from 'react'; | ||
import { memo, useMemo } from 'react'; | ||
|
||
import Favicons from '@/components/Favicons'; | ||
import { useThemeStore } from '@/store'; | ||
import Analytics from '@/components/Analytics'; | ||
import { Provider, createStore, useThemeStore } from '@/store'; | ||
|
||
export default memo(() => { | ||
import Favicons from '../DocLayout/Head/Favicons'; | ||
import Og from '../DocLayout/Head/Og'; | ||
import GlobalStyle from './GlobalStyle'; | ||
|
||
const App = memo(({ initState }: any) => { | ||
const themeMode = useThemeStore((st) => st.themeMode, isEqual); | ||
const outlet = useOutlet(); | ||
|
||
return ( | ||
<> | ||
<Provider createStore={() => createStore(initState)}> | ||
<Favicons /> | ||
<ThemeProvider themeMode={themeMode}>{outlet}</ThemeProvider> | ||
</> | ||
<Og /> | ||
<Analytics /> | ||
<ThemeProvider themeMode={themeMode}> | ||
<GlobalStyle /> | ||
{outlet} | ||
</ThemeProvider> | ||
</Provider> | ||
); | ||
}); | ||
|
||
export default memo(() => { | ||
const siteData = useSiteData(); | ||
const sidebar = useSidebarData(); | ||
const routeMeta = useRouteMeta(); | ||
const tabMeta = useTabMeta(); | ||
const navData = useNavData(); | ||
const location = useLocation(); | ||
const locale = useLocale(); | ||
|
||
const initState = useMemo( | ||
() => ({ locale, location, navData, routeMeta, sidebar, siteData, tabMeta }), | ||
[], | ||
); | ||
|
||
return <App initState={initState} />; | ||
}); |
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,24 +1,23 @@ | ||
import { createGlobalStyle } from 'antd-style'; | ||
|
||
const GlobalStyle = createGlobalStyle` | ||
#nprogress { | ||
.bar { | ||
background: ${({ theme }) => theme.colorText}; | ||
} | ||
.peg { | ||
display: none !important; | ||
} | ||
.spinner { | ||
display: none; | ||
#root { | ||
min-height: 100vh; | ||
} | ||
} | ||
#nprogress { | ||
.bar { | ||
background: ${({ theme }) => theme.colorText}; | ||
} | ||
.peg { | ||
display: none !important; | ||
} | ||
.spinner { | ||
display: none; | ||
} | ||
} | ||
`; | ||
|
||
export default GlobalStyle; |
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,24 @@ | ||
import { Helmet } from 'dumi'; | ||
import isEqual from 'fast-deep-equal'; | ||
import { memo } from 'react'; | ||
|
||
import { siteSelectors, useSiteStore } from '@/store'; | ||
|
||
const Favicons = memo(() => { | ||
const [title, logo] = useSiteStore((s) => [siteSelectors.siteTitle(s), siteSelectors.logo(s)]); | ||
const metadata = useSiteStore(siteSelectors.metadata, isEqual); | ||
return ( | ||
<Helmet> | ||
<link href={metadata?.icons?.apple || logo} rel="apple-touch-icon" sizes="180x180" /> | ||
<link href={metadata?.icons?.shortcut || logo} rel="icon" sizes="32x32" type="image/png" /> | ||
<link href={metadata?.icons?.shortcut || logo} rel="shortcut icon" type="image/x-icon" /> | ||
{metadata?.manifest && <link href={metadata?.manifest} rel="manifest" />} | ||
<meta content={title} name="apple-mobile-web-app-title" /> | ||
<meta content={title} name="application-name" /> | ||
<meta content="#f8f8f8" media="(prefers-color-scheme: light)" name="theme-color" /> | ||
<meta content="#000" media="(prefers-color-scheme: dark)" name="theme-color" /> | ||
</Helmet> | ||
); | ||
}); | ||
|
||
export default Favicons; |
Oops, something went wrong.