Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 2 additions & 22 deletions packages/docs-support/src/side-nav.gts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import Component from '@glimmer/component';
import { on } from '@ember/modifier';
import { service } from '@ember/service';

import { sentenceCase } from 'change-case';
import { link } from 'ember-primitives/helpers';
import { PageNav } from 'kolay/components';
import { getAnchor } from 'should-handle-link';

import type { TOC } from '@ember/component/template-only';
import type RouterService from '@ember/routing/router-service';
import type { Page } from 'kolay';

type CustomPage = Page & {
Expand All @@ -26,18 +24,6 @@ function fixWords(text: string) {
}
}

const joinUrl = (...strs: string[]) => {
const prefix = strs[0]?.startsWith('/') ? '/' : '';

return (
prefix +
strs
.map((s) => s.replace(/^\//, '').replace(/\/$/, ''))
.filter((x) => !!x)
.join('/')
);
};

/**
* Converts 1-2-hyphenated-thing
* to
Expand Down Expand Up @@ -114,12 +100,6 @@ export class SideNav extends Component<{
onClick?: () => void;
};
}> {
@service('router') declare router: RouterService;

get rootUrl() {
return this.router.rootURL;
}

closeNav = (event: Event) => {
if (!getAnchor(event)) return;

Expand All @@ -143,7 +123,7 @@ export class SideNav extends Component<{
<PageNav aria-label="Main Navigation">
<:page as |x|>
<SubSectionLink
@href={{joinUrl this.rootUrl x.page.path}}
@href={{x.page.path}}
@name={{nameFor x.page}}
{{on "click" this.closeNav}}
/>
Expand All @@ -152,7 +132,7 @@ export class SideNav extends Component<{
<:collection as |x|>
{{#if x.index}}
<SectionLink
@href={{joinUrl this.rootUrl x.index.page.path}}
@href={{x.index.page.path}}
@name={{titleize x.collection.name}}
{{on "click" this.closeNav}}
/>
Expand Down
Loading