Skip to content
This repository was archived by the owner on Jul 3, 2025. It is now read-only.

Commit 0a9124e

Browse files
committed
Merge branch 'chore/migrate-next11' of https://github.com/yokinist/nobelium into yokinist-chore/migrate-next11
2 parents d13e14f + 59b8287 commit 0a9124e

7 files changed

Lines changed: 93 additions & 64 deletions

File tree

.eslintrc.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ module.exports = {
2323
}
2424
},
2525
rules: {
26-
'react/prop-types': 'off',
27-
'import/no-anonymous-default-export': [
28-
2,
29-
{
30-
allowArrowFunction: true
31-
}
32-
]
26+
'react/prop-types': 'off'
3327
},
3428
globals: {
3529
React: true

components/Pagination.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,26 @@ const Pagination = ({ page, showNext }) => {
1414
: `/page/${currentPage - 1}`
1515
}
1616
>
17-
<button
18-
rel="prev"
19-
className={`${
20-
currentPage === 1 ? 'invisible' : 'block'
21-
} cursor-pointer`}
22-
>
23-
{locale.PAGINATION.PREV}
24-
</button>
17+
<a>
18+
<button
19+
rel="prev"
20+
className={`${
21+
currentPage === 1 ? 'invisible' : 'block'
22+
} cursor-pointer`}
23+
>
24+
{locale.PAGINATION.PREV}
25+
</button>
26+
</a>
2527
</Link>
2628
<Link href={`/page/${currentPage + 1}`}>
27-
<button
28-
rel="next"
29-
className={`${+showNext ? 'block' : 'invisible'} cursor-pointer`}
30-
>
31-
{locale.PAGINATION.NEXT}
32-
</button>
29+
<a>
30+
<button
31+
rel="next"
32+
className={`${+showNext ? 'block' : 'invisible'} cursor-pointer`}
33+
>
34+
{locale.PAGINATION.NEXT}
35+
</button>
36+
</a>
3337
</Link>
3438
</div>
3539
)

components/Scripts.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import Script from 'next/script'
2+
import BLOG from '@/blog.config'
3+
4+
const Scripts = () => (
5+
<>
6+
{BLOG.analytics && BLOG.analytics.provider === 'ackee' && (
7+
<Script
8+
src={BLOG.analytics.ackeeConfig.tracker}
9+
data-ackee-server={BLOG.analytics.ackeeConfig.dataAckeeServer}
10+
data-ackee-domain-id={BLOG.analytics.ackeeConfig.domainId}
11+
/>
12+
)}
13+
{BLOG.autoCollapsedNavBar === true && (
14+
<Script strategy="lazyOnload">
15+
{`var windowTop=0;
16+
function scrollTrigger(){
17+
let scrollS = window.scrollY;
18+
let nav = document.querySelector('.sticky-nav');
19+
if(scrollS >= windowTop){
20+
nav.style.opacity = 0;
21+
windowTop = scrollS;
22+
}else{
23+
nav.style.opacity = 1;
24+
windowTop = scrollS;
25+
}
26+
};
27+
window.addEventListener('scroll',scrollTrigger);`}
28+
</Script>
29+
)}
30+
{BLOG.analytics && BLOG.analytics.provider === 'ga' && (
31+
<>
32+
<Script
33+
src={`https://www.googletagmanager.com/gtag/js?id=${BLOG.analytics.gaConfig.measurementId}`}
34+
/>
35+
<Script strategy="lazyOnload">
36+
{`window.dataLayer = window.dataLayer || [];
37+
function gtag(){dataLayer.push(arguments);}
38+
gtag('js', new Date());
39+
gtag('config', '${BLOG.analytics.gaConfig.measurementId}', {
40+
page_path: window.location.pathname,
41+
});`}
42+
</Script>
43+
</>
44+
)}
45+
</>
46+
)
47+
48+
export default Scripts

next.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ module.exports = {
33
images: {
44
domains: ['gravatar.com']
55
},
6+
eslint: {
7+
dirs: [
8+
'components',
9+
'layouts',
10+
'lib',
11+
'pages'
12+
]
13+
},
614
async headers() {
715
return [
816
{

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"dev": "next dev",
1717
"build": "next build",
1818
"start": "next start",
19-
"postbuild": "next-sitemap --config next-sitemap.config.js",
20-
"lint": "next lint"
19+
"lint": "next lint",
20+
"postbuild": "next-sitemap --config next-sitemap.config.js"
2121
},
2222
"dependencies": {
2323
"feed": "^4.2.2",

pages/_app.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,28 @@ import '@/styles/notion.css'
66
import BLOG from '@/blog.config'
77
import dynamic from 'next/dynamic'
88
import { LocaleProvider } from '@/lib/locale'
9+
import Scripts from '@/components/Scripts'
910

1011
const Ackee = dynamic(() => import('@/components/Ackee'), { ssr: false })
1112
const Gtag = dynamic(() => import('@/components/Gtag'), { ssr: false })
1213

1314
function MyApp({ Component, pageProps }) {
1415
return (
15-
<LocaleProvider>
16-
<>
17-
{BLOG.isProd && BLOG?.analytics?.provider === 'ackee' && (
18-
<Ackee
19-
ackeeServerUrl={BLOG.analytics.ackeeConfig.dataAckeeServer}
20-
ackeeDomainId={BLOG.analytics.ackeeConfig.domainId}
21-
/>
22-
)}
23-
{BLOG.isProd && BLOG?.analytics?.provider === 'ga' && <Gtag />}
24-
<Component {...pageProps} />
25-
</>
26-
</LocaleProvider>
16+
<>
17+
<Scripts />
18+
<LocaleProvider>
19+
<>
20+
{BLOG.isProd && BLOG?.analytics?.provider === 'ackee' && (
21+
<Ackee
22+
ackeeServerUrl={BLOG.analytics.ackeeConfig.dataAckeeServer}
23+
ackeeDomainId={BLOG.analytics.ackeeConfig.domainId}
24+
/>
25+
)}
26+
{BLOG.isProd && BLOG?.analytics?.provider === 'ga' && <Gtag />}
27+
<Component {...pageProps} />
28+
</>
29+
</LocaleProvider>
30+
</>
2731
)
2832
}
2933

pages/_document.js

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -82,37 +82,8 @@ class MyDocument extends Document {
8282
</noscript>
8383
</>
8484
)}
85-
8685
<link rel="icon" href="/favicon.ico" />
8786
<link rel="icon" href="/favicon.svg" type="image/svg+xml"></link>
88-
{BLOG.analytics && BLOG.analytics.provider === 'ackee' && (
89-
<script
90-
async
91-
src={BLOG.analytics.ackeeConfig.tracker}
92-
data-ackee-server={BLOG.analytics.ackeeConfig.dataAckeeServer}
93-
data-ackee-domain-id={BLOG.analytics.ackeeConfig.domainId}
94-
></script>
95-
)}
96-
{BLOG.analytics && BLOG.analytics.provider === 'ga' && (
97-
<>
98-
<script
99-
async
100-
src={`https://www.googletagmanager.com/gtag/js?id=${BLOG.analytics.gaConfig.measurementId}`}
101-
/>
102-
<script
103-
dangerouslySetInnerHTML={{
104-
__html: `
105-
window.dataLayer = window.dataLayer || [];
106-
function gtag(){dataLayer.push(arguments);}
107-
gtag('js', new Date());
108-
gtag('config', '${BLOG.analytics.gaConfig.measurementId}', {
109-
page_path: window.location.pathname,
110-
});
111-
`
112-
}}
113-
/>
114-
</>
115-
)}
11687
</Head>
11788
<body className="bg-day dark:bg-night">
11889
<Main />

0 commit comments

Comments
 (0)