Skip to content

Commit

Permalink
add cache and base path
Browse files Browse the repository at this point in the history
  • Loading branch information
timlrx committed Nov 21, 2023
1 parent f38403a commit be50f97
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
33 changes: 29 additions & 4 deletions .github/workflows/nextjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,42 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18'
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: Restore cache
uses: actions/cache@v3
with:
path: |
.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- name: Install dependencies
run: yarn install
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: Build project assets
run: |
yarn build
touch out/.nojekyll
run: ${{ steps.detect-package-manager.outputs.manager }} build
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
Expand Down
7 changes: 3 additions & 4 deletions components/Image.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable jsx-a11y/alt-text */
/* eslint-disable @next/next/no-img-element */
import NextImage, { ImageProps } from 'next/image'

// @ts-ignore
const Image = ({ ...rest }: ImageProps) => <img {...rest} />
const Image = ({ src, ...rest }: ImageProps) => (
<NextImage src={`/tailwind-nextjs-starter-blog${src}`} {...rest} />
)

export default Image
2 changes: 2 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ module.exports = () => {
eslint: {
dirs: ['app', 'components', 'layouts', 'scripts'],
},
basePath: "/tailwind-nextjs-starter-blog",
output: 'export',
images: {
remotePatterns: [
Expand All @@ -73,6 +74,7 @@ module.exports = () => {
hostname: 'picsum.photos',
},
],
unoptimized: true,
},
// async headers() {
// return [
Expand Down

0 comments on commit be50f97

Please sign in to comment.