File tree Expand file tree Collapse file tree 4 files changed +28
-9
lines changed
Expand file tree Collapse file tree 4 files changed +28
-9
lines changed Original file line number Diff line number Diff line change 2222 npm ci
2323 npm run build
2424
25- - name : Rename _next directory
26- run : mv build/_next build/static-assets # Rename _next to static-assets
27-
2825 - name : Deploy 🚀
2926 uses : JamesIves/github-pages-deploy-action@v4
3027 with :
3128 branch : gh-pages
32- folder : build
33- token : ${{ secrets.GITHUB_TOKEN }}
29+ folder : out
30+ token : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change 11/** @type {import('next').NextConfig } */
22const nextConfig = {
33 output : 'export' ,
4- distDir : 'build' ,
54 basePath : '' ,
6- assetPrefix : 'https://vaqm2.github.io/static-assets/ ' ,
5+ assetPrefix : '' ,
76 images : {
87 unoptimized : true ,
98 } ,
109} ;
1110
12- export default nextConfig ;
11+ export default nextConfig ;
Original file line number Diff line number Diff line change 66 "dev" : " next dev --turbopack" ,
77 "build" : " next build" ,
88 "start" : " next start" ,
9- "lint" : " next lint" ,
9+ "lint" : " next lint" ,
10+ "postbuild" : " node scripts/fix-paths.js"
11+ },,
1012 "deploy" : " gh-pages -d out"
1113 },
1214 "dependencies" : {
Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' ) ;
2+ const path = require ( 'path' ) ;
3+
4+ const buildDir = path . join ( process . cwd ( ) , 'out' ) ;
5+
6+ function fixPaths ( dir ) {
7+ fs . readdirSync ( dir ) . forEach ( file => {
8+ const filePath = path . join ( dir , file ) ;
9+ if ( fs . statSync ( filePath ) . isDirectory ( ) ) {
10+ fixPaths ( filePath ) ;
11+ } else if ( filePath . endsWith ( '.html' ) ) {
12+ let content = fs . readFileSync ( filePath , 'utf8' ) ;
13+ content = content . replace ( / _ n e x t \/ s t a t i c \/ c s s / g, 'static/css' ) ;
14+ content = content . replace ( / _ n e x t \/ s t a t i c \/ m e d i a / g, 'static/media' ) ;
15+ fs . writeFileSync ( filePath , content ) ;
16+ }
17+ } ) ;
18+ }
19+
20+ fixPaths ( buildDir ) ;
21+ console . log ( 'Fixed asset paths in HTML files.' ) ;
You can’t perform that action at this time.
0 commit comments