ytify icon indicating copy to clipboard operation
ytify copied to clipboard

GitHub pages fix

Open error-reporting opened this issue 1 month ago • 4 comments

I added patches and changes to fix GitHub pages hosting

Summary by CodeRabbit

  • New Features

    • Added GitHub Pages deployment support with configurable base path for subdirectory hosting.
  • Improvements

    • Updated navigation links to use relative paths for improved routing consistency.
    • Modified cache clearing behavior to use navigation instead of full page reload, preserving user session state.

error-reporting avatar Nov 09 '25 11:11 error-reporting

[!IMPORTANT]

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request establishes GitHub Pages deployment infrastructure and refactors the application to support a configurable base path, converting absolute paths to relative paths throughout while introducing route normalization logic in the router.

Changes

Cohort / File(s) Summary
GitHub Pages Deployment
.github/workflows/deploy.yml
New workflow that builds and deploys the application to GitHub Pages on pushes to main, deriving the base path from repository name and passing it to the build via VITE_BASE_PATH environment variable.
Build & Base Path Configuration
vite.config.ts
Added base property to Vite config using VITE_BASE_PATH environment variable; updated PWA manifest resource references (shortcuts, start_url) from absolute root paths to relative paths.
Navigation Path Updates
index.html, src/components/Settings/library.ts
Converted navigation anchor links and route comparisons from absolute paths (e.g., /library, /search) to relative paths (e.g., ./library, ./search).
Route Normalization Logic
src/scripts/router.ts
Introduced base URL constant from environment and applied normalization across route comparisons, lookups, navigation, and state management by consistently replacing the base path with / before route resolution.
Cache Clearing Navigation
src/components/Settings/index.ts
Changed cache clearing behavior from full page reload to targeted navigation to the base path via history.pushState.
Version Control Configuration
.gitignore
Removed package-lock.json from ignore rules to enable tracking in version control.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Router as Router
    participant NavHandler as Navigation Handler
    participant History as Browser History
    
    User->>Router: Click navigation link (e.g., anchor.id = "./list")
    Router->>Router: Normalize: pathname.replace(base, '/')
    Router->>NavHandler: Route resolved to /list
    NavHandler->>History: pushState(base + "/list")
    History-->>User: URL updated to origin + base + /list
    
    Note over Router: All route comparisons<br/>use normalized path

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • src/scripts/router.ts: Requires careful verification that base path normalization is applied consistently across all route comparisons, state restoration, and navigation handlers; potential edge cases with missing base or falsy base values.
  • .github/workflows/deploy.yml: Verify that VITE_BASE_PATH construction from repository name produces correct URLs for subpath deployments.
  • Interaction between files: Ensure relative path changes across HTML, config, and router logic align consistently to prevent broken navigation or routing loops.

Poem

🐰 A hop down the path of the base we define, No longer absolute, now routes align! From root to subdirectory, smooth as can be, GitHub's own Pages deploys with glee! With package locks tracked and paths made anew, This application leaps forward—hippity-hoo! 🌟

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'GitHub pages fix' accurately reflects the main objective of the changeset, which is to enable GitHub Pages hosting by adjusting paths, adding a deployment workflow, and configuring base URLs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Nov 09 '25 11:11 coderabbitai[bot]

also remind users of my https://error-reporting.github.io/ytify-legacy/ instance not to use the restore settings button as that has the /?e= 404 problem too in the readme or I could/should patch that too?

error-reporting avatar Nov 09 '25 12:11 error-reporting

the restore settings button as that has the /?e= 404 problem too in the readme or I could/should patch that too?

Ofcourse

n-ce avatar Nov 09 '25 13:11 n-ce

@error-reporting is attempting to deploy a commit to the nce's projects Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Nov 09 '25 14:11 vercel[bot]