Skip to content

Implement Embla router with SPA support#13

Merged
thorbeck merged 1 commit intomainfrom
feature/routing
Feb 4, 2026
Merged

Implement Embla router with SPA support#13
thorbeck merged 1 commit intomainfrom
feature/routing

Conversation

@thorbeck
Copy link
Owner

@thorbeck thorbeck commented Feb 4, 2026

Introduce the Embla router to enable single-page application functionality, allowing for dynamic routing and page components. This update includes the creation of various page components and a redirect script for GitHub Pages.

Copilot AI review requested due to automatic review settings February 4, 2026 06:52
@thorbeck thorbeck merged commit 07a9233 into main Feb 4, 2026
3 of 6 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces the Embla router to enable single-page application functionality with dynamic routing and page components. The implementation replaces the static content with a router-based navigation system and includes GitHub Pages compatibility through a custom redirect mechanism.

Changes:

  • Integrated the Embla router library and created five page components (home, about, articles, article, and 404)
  • Replaced static HTML content with router configuration supporting both static and dynamic routes
  • Added GitHub Pages SPA support through a redirect script in 404.html and query parameter handling in index.html

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/index.ts Added router and page component imports to initialize the SPA
src/components/page-home/page-home.tsx Created home page component with navigation links
src/components/page-about/page-about.tsx Created about page component with router demonstration description
src/components/page-articles/page-articles.tsx Created articles listing page with sample article links
src/components/page-article/page-article.tsx Created dynamic article page that displays route parameters
src/components/page-notfound/page-notfound.tsx Created 404 error page component
index.html Replaced static content with router configuration and added SPA redirect script
404.html Created GitHub Pages redirect handler to support client-side routing

this.render();
}

attributeChangedCallback(_name: string, oldValue: string, newValue: string) {
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter '_name' is prefixed with underscore to indicate it's unused, but it's included in the observedAttributes list. Consider renaming to 'name' if it's meaningful, or document why it's intentionally unused.

Suggested change
attributeChangedCallback(_name: string, oldValue: string, newValue: string) {
attributeChangedCallback(name: string, oldValue: string, newValue: string) {

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +13
const pathSegments = window.location.pathname.slice(1).split('/').filter(Boolean);
const redirectPath = pathSegments.length > 0
? '/?p=/' + pathSegments.join('/')
: '/';
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The redirect logic constructs the path with string concatenation which could lead to double slashes. When pathSegments is empty but the original path had a trailing slash, or when joining segments that might contain edge cases. Consider using a more robust path construction approach or add a comment explaining the expected input format.

Suggested change
const pathSegments = window.location.pathname.slice(1).split('/').filter(Boolean);
const redirectPath = pathSegments.length > 0
? '/?p=/' + pathSegments.join('/')
: '/';
const pathSegments = window.location.pathname
.slice(1)
.split('/')
.filter(Boolean);
function buildRedirectPath(segments) {
if (!segments || segments.length === 0) {
return '/';
}
// Normalize segments to avoid accidental double slashes
const normalized = segments
.map(function (segment) {
return segment.replace(/^\/+|\/+$/g, '');
})
.filter(Boolean)
.join('/');
return normalized ? '/?p=/' + normalized : '/';
}
const redirectPath = buildRedirectPath(pathSegments);

Copilot uses AI. Check for mistakes.
@thorbeck thorbeck deleted the feature/routing branch February 4, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments