File tree Expand file tree Collapse file tree 5 files changed +64
-8
lines changed
Expand file tree Collapse file tree 5 files changed +64
-8
lines changed Original file line number Diff line number Diff line change 1+ name : Deploy to GitHub Pages
2+
3+ on :
4+ workflow_dispatch :
5+
6+ permissions :
7+ contents : read
8+ pages : write
9+ id-token : write
10+
11+ concurrency :
12+ group : ' pages'
13+ cancel-in-progress : true
14+
15+ jobs :
16+ deploy :
17+ environment :
18+ name : github-pages
19+ url : ${{ steps.deployment.outputs.page_url }}
20+ runs-on : ubuntu-latest
21+ steps :
22+ - name : Checkout
23+ uses : actions/checkout@v4
24+ - name : Set up Node
25+ uses : actions/setup-node@v4
26+ with :
27+ node-version : lts/*
28+ cache : ' npm'
29+ - name : Install dependencies
30+ run : yarn install --frozen-lockfile
31+ - name : Build
32+ run : yarn build
33+ env :
34+ # VITE_BYTEBIN_URL: "https://your-bytebin.example.com/"
35+ VITE_USE_QUERY_ROUTING : " true" # required for github pages
36+ - name : Setup Pages
37+ uses : actions/configure-pages@v5
38+ - name : Upload artifact
39+ uses : actions/upload-pages-artifact@v3
40+ with :
41+ # Upload dist folder
42+ path : ' ./dist'
43+ - name : Deploy to GitHub Pages
44+ id : deployment
45+ uses : actions/deploy-pages@v4
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import Editor from './components/Editor';
55import usePreference from './hooks/usePreference.ts' ;
66import themes , { Themes } from './style/themes.ts' ;
77import { loadFromBytebin } from './util/storage' ;
8+ import { useQueryRouting } from './util/constants' ;
89
910const INITIAL = Symbol ( ) ;
1011const LOADING = Symbol ( ) ;
@@ -81,10 +82,10 @@ function get404Message(pasteId: string) {
8182}
8283
8384function getPasteIdFromUrl ( ) {
84- const path = window . location . pathname ;
85- if ( path && / ^ \/ [ a - z A - Z 0 - 9 ] + $ / . test ( path ) ) {
86- return path . substring ( 1 ) ;
87- } else {
88- return undefined ;
85+ if ( useQueryRouting ) {
86+ return new URLSearchParams ( window . location . search ) . get ( 'id' ) ?? undefined ;
8987 }
88+
89+ const path = window . location . pathname ;
90+ return / ^ \/ [ a - z A - Z 0 - 9 ] + $ / . test ( path ) ? path . substring ( 1 ) : undefined ;
9091}
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import styled from 'styled-components';
66import themes , { Themes } from '../style/themes' ;
77import { languages } from '../util/highlighting' ;
88import { saveToBytebin } from '../util/storage' ;
9+ import { useQueryRouting } from '../util/constants' ;
910import Button from './Button' ;
1011import { ResetFunction } from './Editor' ;
1112import MenuButton from './MenuButton' ;
@@ -59,9 +60,15 @@ export default function EditorControls({
5960 setSaving ( false ) ;
6061 setRecentlySaved ( true ) ;
6162 if ( pasteId ) {
62- history . replace ( {
63- pathname : pasteId ,
64- } ) ;
63+ if ( useQueryRouting ) {
64+ history . replace ( {
65+ search : `?id=${ pasteId } ` ,
66+ } ) ;
67+ } else {
68+ history . replace ( {
69+ pathname : pasteId ,
70+ } ) ;
71+ }
6572 copy ( window . location . href ) ;
6673 document . title = 'paste | ' + pasteId ;
6774 }
Original file line number Diff line number Diff line change 11export const bytebinUrl =
22 import . meta. env . VITE_BYTEBIN_URL || 'https://bytebin.lucko.me/' ;
33export const postUrl = bytebinUrl + 'post' ;
4+ export const useQueryRouting =
5+ import . meta. env . VITE_USE_QUERY_ROUTING === 'true' ;
Original file line number Diff line number Diff line change 22
33interface ImportMetaEnv {
44 readonly VITE_BYTEBIN_URL ?: string ;
5+ readonly VITE_USE_QUERY_ROUTING ?: string ;
56}
67
78interface ImportMeta {
You can’t perform that action at this time.
0 commit comments