Skip to content

Commit

Permalink
feat: add gh-pages deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
diogomoretti committed Dec 6, 2024
1 parent fc54cfd commit ca456e9
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 4 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/deploy-demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Deploy Demo

on:
push:
branches: [ main ]

permissions:
contents: write

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install Dependencies
run: npm install

- name: Build Demo
run: npm run build:demo

- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: demo
branch: gh-pages
79 changes: 79 additions & 0 deletions demo/assets/index-BbRll3oi.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions demo/assets/index-Oplo2xSH.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>useQRCode</title>

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Geist+Mono:[email protected]&display=swap" rel="stylesheet">
<script type="module" crossorigin src="/assets/index-BbRll3oi.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-Oplo2xSH.css">
</head>
<body>
<div id="root"></div>
</body>
</html>
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"test": "vitest",
"test:coverage": "vitest run --coverage",
"release": "npm run build && npm publish --access public && npm run publish-tag",
"publish-tag": "PACKAGE_VERSION=$(cat package.json | grep \\\"version\\\" | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag v$PACKAGE_VERSION && git push --tags"
"publish-tag": "PACKAGE_VERSION=$(cat package.json | grep \\\"version\\\" | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag v$PACKAGE_VERSION && git push --tags",
"build:demo": "vite build --config vite.demo.config.ts"
},
"peerDependencies": {
"react": ">=16.8.0",
Expand Down
6 changes: 3 additions & 3 deletions src/components/QRCodeDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const QRCodeDemo = () => {
</div>
<h1 className="qr-title">useQRCode</h1>
<div className="qr-github">
<a href="https://github.com/mattrothenberg/useQRCode">
<a href="https://github.com/diogomoretti/use-qrcode-hook">
View on GitHub
</a>
</div>
Expand Down Expand Up @@ -106,7 +106,7 @@ export const QRCodeDemo = () => {
<h2 className="usage-title">How to Use</h2>
<div className="code-block">
<SyntaxHighlighter language="javascript" style={irBlack}>
{`import useQRCode from 'use-qrcode';
{`import useQRCode from 'use-qrcode-hook';
const MyComponent = () => {
const { qrCodeDataUrl, error, isLoading } = useQRCode('https://example.com', {
Expand All @@ -119,7 +119,7 @@ const MyComponent = () => {
if (isLoading) return <div>Loading...</div>;
if (error) return <div>Error: {error.message}</div>;
return <img src={qrCodeDataUrl} alt="QR Code" />;
};`}
</SyntaxHighlighter>
Expand Down
10 changes: 10 additions & 0 deletions vite.demo.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
plugins: [react()],
base: './src',
build: {
outDir: 'demo',
},
});

0 comments on commit ca456e9

Please sign in to comment.