From 831009f887e0e1bc7047af406cb6ca32ff35a6b0 Mon Sep 17 00:00:00 2001 From: MusherM Date: Wed, 29 May 2024 07:03:53 +0000 Subject: [PATCH] deploy: e7e65ac7d08db53474e1e82c49b1cc32db4764b4 --- 404.html | 2 +- .../index.json | 0 .../sci-fi-title-generator.json | 0 .../search.json | 0 .../tag/Next.js.json | 0 .../tag/React.json | 0 .../tag/Website.json | 0 _next/static/WKGDdj_e8H8WZdqUKvPqy/_ssgManifest.js | 1 - .../_buildManifest.js | 0 .../_middlewareManifest.js | 0 _next/static/b5uVlbnWOBrgRqRu80rD1/_ssgManifest.js | 1 + feed.xml | 2 +- index.html | 2 +- sci-fi-title-generator.html | 4 ++-- search.html | 2 +- sitemap.xml | 12 ++++++------ tag/Next.js.html | 2 +- tag/React.html | 2 +- tag/Website.html | 2 +- 19 files changed, 16 insertions(+), 16 deletions(-) rename _next/data/{WKGDdj_e8H8WZdqUKvPqy => b5uVlbnWOBrgRqRu80rD1}/index.json (100%) rename _next/data/{WKGDdj_e8H8WZdqUKvPqy => b5uVlbnWOBrgRqRu80rD1}/sci-fi-title-generator.json (100%) rename _next/data/{WKGDdj_e8H8WZdqUKvPqy => b5uVlbnWOBrgRqRu80rD1}/search.json (100%) rename _next/data/{WKGDdj_e8H8WZdqUKvPqy => b5uVlbnWOBrgRqRu80rD1}/tag/Next.js.json (100%) rename _next/data/{WKGDdj_e8H8WZdqUKvPqy => b5uVlbnWOBrgRqRu80rD1}/tag/React.json (100%) rename _next/data/{WKGDdj_e8H8WZdqUKvPqy => b5uVlbnWOBrgRqRu80rD1}/tag/Website.json (100%) delete mode 100644 _next/static/WKGDdj_e8H8WZdqUKvPqy/_ssgManifest.js rename _next/static/{WKGDdj_e8H8WZdqUKvPqy => b5uVlbnWOBrgRqRu80rD1}/_buildManifest.js (100%) rename _next/static/{WKGDdj_e8H8WZdqUKvPqy => b5uVlbnWOBrgRqRu80rD1}/_middlewareManifest.js (100%) create mode 100644 _next/static/b5uVlbnWOBrgRqRu80rD1/_ssgManifest.js diff --git a/404.html b/404.html index 138130922..cc1548a2f 100644 --- a/404.html +++ b/404.html @@ -1 +1 @@ -404: This page could not be found

404

This page could not be found.

\ No newline at end of file +404: This page could not be found

404

This page could not be found.

\ No newline at end of file diff --git a/_next/data/WKGDdj_e8H8WZdqUKvPqy/index.json b/_next/data/b5uVlbnWOBrgRqRu80rD1/index.json similarity index 100% rename from _next/data/WKGDdj_e8H8WZdqUKvPqy/index.json rename to _next/data/b5uVlbnWOBrgRqRu80rD1/index.json diff --git a/_next/data/WKGDdj_e8H8WZdqUKvPqy/sci-fi-title-generator.json b/_next/data/b5uVlbnWOBrgRqRu80rD1/sci-fi-title-generator.json similarity index 100% rename from _next/data/WKGDdj_e8H8WZdqUKvPqy/sci-fi-title-generator.json rename to _next/data/b5uVlbnWOBrgRqRu80rD1/sci-fi-title-generator.json diff --git a/_next/data/WKGDdj_e8H8WZdqUKvPqy/search.json b/_next/data/b5uVlbnWOBrgRqRu80rD1/search.json similarity index 100% rename from _next/data/WKGDdj_e8H8WZdqUKvPqy/search.json rename to _next/data/b5uVlbnWOBrgRqRu80rD1/search.json diff --git a/_next/data/WKGDdj_e8H8WZdqUKvPqy/tag/Next.js.json b/_next/data/b5uVlbnWOBrgRqRu80rD1/tag/Next.js.json similarity index 100% rename from _next/data/WKGDdj_e8H8WZdqUKvPqy/tag/Next.js.json rename to _next/data/b5uVlbnWOBrgRqRu80rD1/tag/Next.js.json diff --git a/_next/data/WKGDdj_e8H8WZdqUKvPqy/tag/React.json b/_next/data/b5uVlbnWOBrgRqRu80rD1/tag/React.json similarity index 100% rename from _next/data/WKGDdj_e8H8WZdqUKvPqy/tag/React.json rename to _next/data/b5uVlbnWOBrgRqRu80rD1/tag/React.json diff --git a/_next/data/WKGDdj_e8H8WZdqUKvPqy/tag/Website.json b/_next/data/b5uVlbnWOBrgRqRu80rD1/tag/Website.json similarity index 100% rename from _next/data/WKGDdj_e8H8WZdqUKvPqy/tag/Website.json rename to _next/data/b5uVlbnWOBrgRqRu80rD1/tag/Website.json diff --git a/_next/static/WKGDdj_e8H8WZdqUKvPqy/_ssgManifest.js b/_next/static/WKGDdj_e8H8WZdqUKvPqy/_ssgManifest.js deleted file mode 100644 index 816b901b8..000000000 --- a/_next/static/WKGDdj_e8H8WZdqUKvPqy/_ssgManifest.js +++ /dev/null @@ -1 +0,0 @@ -self.__SSG_MANIFEST=new Set(["\u002F","\u002Fsearch","\u002Fpage\u002F[page]","\u002Ftag\u002F[tag]","\u002F[slug]"]);self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB() \ No newline at end of file diff --git a/_next/static/WKGDdj_e8H8WZdqUKvPqy/_buildManifest.js b/_next/static/b5uVlbnWOBrgRqRu80rD1/_buildManifest.js similarity index 100% rename from _next/static/WKGDdj_e8H8WZdqUKvPqy/_buildManifest.js rename to _next/static/b5uVlbnWOBrgRqRu80rD1/_buildManifest.js diff --git a/_next/static/WKGDdj_e8H8WZdqUKvPqy/_middlewareManifest.js b/_next/static/b5uVlbnWOBrgRqRu80rD1/_middlewareManifest.js similarity index 100% rename from _next/static/WKGDdj_e8H8WZdqUKvPqy/_middlewareManifest.js rename to _next/static/b5uVlbnWOBrgRqRu80rD1/_middlewareManifest.js diff --git a/_next/static/b5uVlbnWOBrgRqRu80rD1/_ssgManifest.js b/_next/static/b5uVlbnWOBrgRqRu80rD1/_ssgManifest.js new file mode 100644 index 000000000..beb4efe87 --- /dev/null +++ b/_next/static/b5uVlbnWOBrgRqRu80rD1/_ssgManifest.js @@ -0,0 +1 @@ +self.__SSG_MANIFEST=new Set(["\u002F","\u002Fsearch","\u002Ftag\u002F[tag]","\u002Fpage\u002F[page]","\u002F[slug]"]);self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB() \ No newline at end of file diff --git a/feed.xml b/feed.xml index 41a52cc0a..2b2c0327c 100644 --- a/feed.xml +++ b/feed.xml @@ -4,7 +4,7 @@ Musher's Frontend Coding Blog / 無限進步 - Wed, 29 May 2024 06:36:41 GMT + Wed, 29 May 2024 07:03:50 GMT https://validator.w3.org/feed/docs/rss2.html https://github.com/jpmonette/feed zh-CN diff --git a/index.html b/index.html index 41c4b0f1a..b720d0643 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -Musher's Frontend Coding Blog
\ No newline at end of file +Musher's Frontend Coding Blog
\ No newline at end of file diff --git a/sci-fi-title-generator.html b/sci-fi-title-generator.html index e61121f1c..d1ff99cac 100644 --- a/sci-fi-title-generator.html +++ b/sci-fi-title-generator.html @@ -1,4 +1,4 @@ -Portfolio 项目总结

🏠 Portfolio 项目总结

date
May 29, 2024
slug
sci-fi-title-generator
status
Published
tags
React
Next.js
Website
summary
总结一下使用Nextjs部署github page时遇到的img标签的路径问题
type
Post

静态资源路径问题

/** @type {import('next').NextConfig} */
+Portfolio 项目总结

🏠 Portfolio 项目总结

date
May 29, 2024
slug
sci-fi-title-generator
status
Published
tags
React
Next.js
Website
summary
总结一下使用Nextjs部署github page时遇到的img标签的路径问题
type
Post

静态资源路径问题

/** @type {import('next').NextConfig} */
 const isProd = process.env.NODE_ENV === "production";
 const nextConfig = {
   output: "export",
@@ -23,4 +23,4 @@
   run: ${{ steps.detect-package-manager.outputs.runner }} next build
   env:
     NODE_ENV: production
-    NEXT_PUBLIC_ASSET_PREFIX: /Portofolio

一些环境体操

  1. 为什么需要使用(process.env.NEXT_PUBLIC_ASSET_PREFIX || "") ,而不是在dev环境下将NEXT_PUBLIC_ASSET_PREFIX 这个变量设为空?因为根据我的观察,只要你试图把一个环境变量设为空,他就会变成undefined ,所以干脆就这么写了
  1. 这个basePath也是,他只会更改你的项目的基本地址,不会自动更改你的静态资源的路径,也就是说如果把basePath设为/Portofolio ,你本地的开发环境地址就会从127.0.0.1:3000变成127.0.0.1:3000/Portofolio,
  1. assetPrefix也是同理,没什么卵用,听起来像是能给你的静态资源加个前缀,但是没用

关于basePath和assetPrefix

basePath

该选项用于在一个子路径下部署项目,他主要在两种场景下生效:
  1. Links:当使用next/linknext/router 时,会自动添加basePath,也就是说<Link href="/about">About Page</Link> 会输出<a href="/docs/about">About Page</a>basePath=’/docs’
  1. Image:当使用next/image 时,需要手动添加basePath,就像我做的那样

assetPrefix

该选项仅针对_next/static 下的静态js css资源,不会影响public下的资源,当然,这个选项还是要设的,不然可能css和js也会因为指向根目录而找不到

可能的另一种方式:自定义ImageLoader

使用next/image时,可以通过自定义imageloader的方式,使用一个函数来返回对应的路径,这个函数就可以对src进行路径拼接等处理,以避免出现(process.env.NEXT_PUBLIC_ASSET_PREFIX || "") + icon 这样不优雅的代码
 

© Musher 2019 - 2024

powered by nobelium

\ No newline at end of file + NEXT_PUBLIC_ASSET_PREFIX: /Portofolio

一些环境体操

  1. 为什么需要使用(process.env.NEXT_PUBLIC_ASSET_PREFIX || "") ,而不是在dev环境下将NEXT_PUBLIC_ASSET_PREFIX 这个变量设为空?因为根据我的观察,只要你试图把一个环境变量设为空,他就会变成undefined ,所以干脆就这么写了
  1. 这个basePath也是,他只会更改你的项目的基本地址,不会自动更改你的静态资源的路径,也就是说如果把basePath设为/Portofolio ,你本地的开发环境地址就会从127.0.0.1:3000变成127.0.0.1:3000/Portofolio,
  1. assetPrefix也是同理,没什么卵用,听起来像是能给你的静态资源加个前缀,但是没用

关于basePath和assetPrefix

basePath

该选项用于在一个子路径下部署项目,他主要在两种场景下生效:
  1. Links:当使用next/linknext/router 时,会自动添加basePath,也就是说<Link href="/about">About Page</Link> 会输出<a href="/docs/about">About Page</a>basePath=’/docs’
  1. Image:当使用next/image 时,需要手动添加basePath,就像我做的那样

assetPrefix

该选项仅针对_next/static 下的静态js css资源,不会影响public下的资源,当然,这个选项还是要设的,不然可能css和js也会因为指向根目录而找不到

可能的另一种方式:自定义ImageLoader

使用next/image时,可以通过自定义imageloader的方式,使用一个函数来返回对应的路径,这个函数就可以对src进行路径拼接等处理,以避免出现(process.env.NEXT_PUBLIC_ASSET_PREFIX || "") + icon 这样不优雅的代码
 

© Musher 2019 - 2024

powered by nobelium

\ No newline at end of file diff --git a/search.html b/search.html index a786039cf..a02bcdd3e 100644 --- a/search.html +++ b/search.html @@ -1 +1 @@ -Musher's Frontend Coding Blog
\ No newline at end of file +Musher's Frontend Coding Blog
\ No newline at end of file diff --git a/sitemap.xml b/sitemap.xml index 2f887fda6..61175103f 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -1,9 +1,9 @@ -/daily0.72024-05-29T06:36:41.731Z -//searchdaily0.72024-05-29T06:36:41.731Z -//tag/Reactdaily0.72024-05-29T06:36:41.731Z -//tag/Next.jsdaily0.72024-05-29T06:36:41.731Z -//tag/Websitedaily0.72024-05-29T06:36:41.731Z -//sci-fi-title-generatordaily0.72024-05-29T06:36:41.731Z +/daily0.72024-05-29T07:03:50.638Z +//searchdaily0.72024-05-29T07:03:50.638Z +//tag/Reactdaily0.72024-05-29T07:03:50.638Z +//tag/Next.jsdaily0.72024-05-29T07:03:50.638Z +//tag/Websitedaily0.72024-05-29T07:03:50.638Z +//sci-fi-title-generatordaily0.72024-05-29T07:03:50.638Z \ No newline at end of file diff --git a/tag/Next.js.html b/tag/Next.js.html index 816470203..98d874ae6 100644 --- a/tag/Next.js.html +++ b/tag/Next.js.html @@ -1 +1 @@ -Musher's Frontend Coding Blog
\ No newline at end of file +Musher's Frontend Coding Blog
\ No newline at end of file diff --git a/tag/React.html b/tag/React.html index 131194245..01982c330 100644 --- a/tag/React.html +++ b/tag/React.html @@ -1 +1 @@ -Musher's Frontend Coding Blog
\ No newline at end of file +Musher's Frontend Coding Blog
\ No newline at end of file diff --git a/tag/Website.html b/tag/Website.html index bf26cf4c4..f96acb883 100644 --- a/tag/Website.html +++ b/tag/Website.html @@ -1 +1 @@ -Musher's Frontend Coding Blog
\ No newline at end of file +Musher's Frontend Coding Blog
\ No newline at end of file