Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions src/components/LanguageMenu.astro
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const filterable = languages.length > 6;
<MIcon name="expand-more-rounded" />
</summary>
<div class="d-dd-menu d-lang-menu">
<p class="d-menu-title">{t(lang, 'language')} <small>{current?.name}</small></p>
<p class="d-menu-title">{t(lang, 'language')}</p>
{
filterable && (
<label class="d-lang-filter">
Expand All @@ -44,8 +44,7 @@ const filterable = languages.length > 6;
<a href={inLanguage(language.code)} hreflang={language.code} lang={language.code} aria-current={language.code === lang ? 'true' : undefined}>
<span class="d-lang-code">{language.code}</span>
<span class="d-lang-name">{language.name}</span>
{coverage[language.code] !== undefined && coverage[language.code] < 100 && <small>{coverage[language.code]}%</small>}
{language.code === lang && <MIcon name="check-rounded" />}
{language.code === lang && <MIcon name="check-rounded" />}
</a>
</li>
))
Expand Down
5 changes: 5 additions & 0 deletions src/components/Sidebar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ function tidy(entries: Entry[]): Entry[] {
if (inner.length === 1 && inner[0].type === 'link') {
return inner[0];
}
// The use cases go by their number (UC-002 before UC-010), not by the name of their folder.
const number = (item: Entry): number => Number(/^UC-(\d+)/.exec(item.type === 'link' ? item.label : '')?.[1] ?? Infinity);
if (inner.length > 1 && inner.every((item) => Number.isFinite(number(item)))) {
inner.sort((a, b) => number(a) - number(b));
}
const key = `tech.${entry.label}`;
return {...entry, label: t(route.lang, key) !== key ? t(route.lang, key) : entry.label, entries: inner};
});
Expand Down
19 changes: 19 additions & 0 deletions src/styles/didactika.css
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ dialog.d-search::backdrop { background: rgb(2 8 10 / 60%); backdrop-filter: blur
.sl-markdown-content { font-size: 0.9375rem; line-height: 1.7; }
.sl-markdown-content :not(a, strong, em, del, span, input, code, br, svg, path):not(:where(.not-content *)) + :not(a, strong, em, del, span, input, code, br, svg, path, :where(.not-content *)) { margin-top: 1.1rem; }
.sl-markdown-content .sl-heading-wrapper.level-h2 { margin-top: 2.6rem; padding-top: 1.4rem; border-top: 1px solid var(--line); }
/* The first section of a page needs no line nor room above it: the title already closes the head. */
.sl-markdown-content > .sl-heading-wrapper.level-h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.sl-markdown-content h2 { margin-top: 0; font: 700 1.55rem/1.25 var(--display); letter-spacing: -0.015em; }
.sl-markdown-content h3 { margin-top: 1.9rem; font: 600 1.15rem/1.3 var(--display); }
.sl-markdown-content h2 a, .sl-markdown-content h3 a { color: inherit; }
Expand Down Expand Up @@ -358,6 +360,23 @@ a.d-chip:hover { color: var(--ink); }
.d-lang-list a[aria-current='true'] .d-lang-code { background: var(--accent); color: var(--accent-ink); }
.d-lang-name { flex: 1; }
.d-lang-empty { margin: 0; padding: 0.8rem; color: var(--muted); font-size: 0.85rem; }
.d-lang-list a[aria-current='true'] .mi { margin-inline-start: auto; }

/* On a phone the menu is a sheet over the foot of the screen: full width, large rows, and the page behind it dimmed. */
@media (max-width: 40rem) {
.d-lang[open]::before { content: ''; position: fixed; inset: 0; z-index: 59; background: rgb(2 8 10 / 45%); }
.d-lang .d-dd-menu {
position: fixed; inset: auto 0 0 0; z-index: 60; width: auto; max-width: none; padding: 0.4rem 0.75rem 1rem; border-width: 1px 0 0;
border-radius: 18px 18px 0 0; box-shadow: 0 -12px 40px rgb(2 8 10 / 28%);
}
.d-lang .d-dd-menu::before { content: ''; justify-self: center; width: 2.5rem; height: 0.28rem; margin: 0.3rem 0 0.5rem; border-radius: 99px; background: var(--line); }
.d-menu-title { padding: 0.2rem 0.4rem 0.4rem; font-size: 0.72rem; }
.d-lang-filter { margin: 0.2rem 0 0.4rem; }
.d-lang-filter input { height: 2.6rem; font-size: 1rem; }
.d-lang-list { max-height: 55vh; }
.d-lang-list a { padding: 0.75rem 0.6rem; font-size: 1rem; }
.d-lang-code { min-width: 2.2rem; height: 1.7rem; }
}

/* -------------------------------------------------------------- screenshots ---- */

Expand Down
5 changes: 5 additions & 0 deletions tools/lib/markdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ describe('the pages of a technical model', () => {
assert.equal(out, `[card](${base}/design/use-cases/a/#tests) ![d](${assets}/en/technical/domain/domain-model.svg) [t](${assets}/en/technical/domain/traceability.csv)`);
});

it('writes the address in lower case, as Starlight does with the name of a folder', () => {
const out = resolveRelativeLinks('[card](./use-cases/createSchema/README.md)', 'technical/analysis/index', 'en', base, assets);
assert.equal(out, `[card](${base}/technical/analysis/use-cases/createschema/)`);
});

it('leaves absolute links, anchors, schemes and code as they are', () => {
const text = '[a](https://x.org) [b](#top) [c](/en/x/) [d](page:guides/x)\n```\n[e](./f.md)\n```\n';
assert.equal(resolveRelativeLinks(text, 'technical/index', 'en', base, assets), text);
Expand Down
2 changes: 1 addition & 1 deletion tools/lib/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function resolveRelativeLinks(markdown: string, pageId: string, lang: str
}
const path = parts.join('/');
if (/\.mdx?$/.test(path)) {
const id = path.replace(/\.mdx?$/, '').replace(/(^|\/)README$/, '$1index').replace(/(^|\/)index$/, '');
const id = path.replace(/\.mdx?$/, '').replace(/(^|\/)README$/, '$1index').replace(/(^|\/)index$/, '').toLowerCase(); // Starlight writes every address in lower case (createSchema is createschema)
return `](${base}${id ? `/${id}` : ''}/${anchor})`;
}
return `](${assetBase}/${lang}/${path}${anchor})`;
Expand Down
Loading