Skip to content

Commit

Permalink
fix: router.push showing progress-bar on the same route
Browse files Browse the repository at this point in the history
  • Loading branch information
ndungtse committed Aug 1, 2023
1 parent 56175bc commit f4950bd
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 3 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Vercel Production Deployment
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
push:
branches:
- main
jobs:
Deploy-Production:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Pull Vercel Environment Information
working-directory: ./example
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
working-directory: ./example
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
working-directory: ./example
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Publish to NPM

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run build
- name: Publish package to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"eslint": "8.43.0",
"eslint-config-next": "13.4.7",
"next": "13.4.7",
"next13-progressbar": "../",
"next13-progressbar": "latest",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "5.1.5"
Expand Down
6 changes: 5 additions & 1 deletion example/src/app/providers.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
'use client';

import { Next13ProgressBar } from '../../../dist';
// use this for local testing
// import { Next13ProgressBar } from '../../../dist';

// this for deploying example
import { Next13ProgressBar } from 'next13-progressbar';

const Providers = ({ children }: { children: React.ReactNode }) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next13-progressbar",
"version": "1.0.0",
"version": "1.0.1",
"description": "A ProgressBar for next.js 13 with app directory ",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 2 additions & 0 deletions src/AppProgressBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ export const Next13ProgressBar = React.memo(

export function useRouter() {
const router = useNextRouter();
const pathname = usePathname();

function push(href: string, options?: NavigateOptions) {
if (href === pathname) return Promise.resolve(true);
NProgress.start();
return router.push(href, options);
}
Expand Down

0 comments on commit f4950bd

Please sign in to comment.