Skip to content

Commit 25d82ae

Browse files
authored
Merge branch 'main' into compare-quadrant-chart
2 parents cd795dd + 5eb1627 commit 25d82ae

File tree

7 files changed

+71
-12
lines changed

7 files changed

+71
-12
lines changed

app/components/Package/Versions.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,16 @@ const visibleTagRows = computed(() => {
211211
)
212212
: rowsMaybeFilteredForDeprecation
213213
const first = rows.slice(0, MAX_VISIBLE_TAGS)
214-
const latestTagRow = rows.find(row => row.tag === 'latest')
215-
// Ensure 'latest' tag is always included (at the end) if not already present
216-
if (latestTagRow && !first.includes(latestTagRow)) {
217-
first.pop()
218-
first.push(latestTagRow)
214+
215+
// When no filter is active, ensure 'latest' is always shown (even if not fully loaded)
216+
if (!isFilterActive.value) {
217+
const latestTagRow = rows.find(row => row.tag === 'latest')
218+
if (latestTagRow && !first.includes(latestTagRow)) {
219+
first.pop()
220+
first.push(latestTagRow)
221+
}
219222
}
223+
220224
return first
221225
})
222226

app/components/Readme.vue

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,25 @@ function handleClick(event: MouseEvent) {
112112
.readme :deep([data-level='1']) {
113113
font-size: 1.5rem;
114114
}
115+
115116
.readme :deep([data-level='2']) {
116117
font-size: 1.25rem;
117118
padding-bottom: 0.5rem;
118119
border-bottom: 1px solid var(--border);
119120
}
121+
120122
.readme :deep([data-level='3']) {
121123
font-size: 1.125rem;
122124
}
125+
123126
.readme :deep([data-level='4']) {
124127
font-size: 1rem;
125128
}
129+
126130
.readme :deep([data-level='5']) {
127131
font-size: 0.925rem;
128132
}
133+
129134
.readme :deep([data-level='6']) {
130135
font-size: 0.875rem;
131136
}
@@ -137,9 +142,11 @@ function handleClick(event: MouseEvent) {
137142
.readme :deep(a) {
138143
@apply underline-offset-[0.2rem] underline decoration-1 decoration-fg/30 font-mono text-fg transition-colors duration-200;
139144
}
145+
140146
.readme :deep(a:hover) {
141147
@apply decoration-accent text-accent;
142148
}
149+
143150
.readme :deep(a:focus-visible) {
144151
@apply decoration-accent text-accent;
145152
}
@@ -318,10 +325,12 @@ function handleClick(event: MouseEvent) {
318325
border-inline-start-color: var(--syntax-str);
319326
background: rgba(59, 130, 246, 0.05);
320327
}
328+
321329
.readme :deep(blockquote[data-callout='note']::before) {
322330
content: var(--i18n-note, 'Note');
323331
color: #3b82f6;
324332
}
333+
325334
.readme :deep(blockquote[data-callout='note']::after) {
326335
background-color: #3b82f6;
327336
-webkit-mask: icon('i-lucide:info') no-repeat;
@@ -333,10 +342,12 @@ function handleClick(event: MouseEvent) {
333342
border-inline-start-color: #22c55e;
334343
background: rgba(34, 197, 94, 0.05);
335344
}
345+
336346
.readme :deep(blockquote[data-callout='tip']::before) {
337347
content: var(--i18n-tip, 'Tip');
338348
color: #22c55e;
339349
}
350+
340351
.readme :deep(blockquote[data-callout='tip']::after) {
341352
background-color: #22c55e;
342353
-webkit-mask: icon('i-lucide:lightbulb') no-repeat;
@@ -348,10 +359,12 @@ function handleClick(event: MouseEvent) {
348359
border-inline-start-color: var(--syntax-fn);
349360
background: rgba(168, 85, 247, 0.05);
350361
}
362+
351363
.readme :deep(blockquote[data-callout='important']::before) {
352364
content: var(--i18n-important, 'Important');
353365
color: var(--syntax-fn);
354366
}
367+
355368
.readme :deep(blockquote[data-callout='important']::after) {
356369
background-color: var(--syntax-fn);
357370
-webkit-mask: icon('i-lucide:pin') no-repeat;
@@ -363,10 +376,12 @@ function handleClick(event: MouseEvent) {
363376
border-inline-start-color: #eab308;
364377
background: rgba(234, 179, 8, 0.05);
365378
}
379+
366380
.readme :deep(blockquote[data-callout='warning']::before) {
367381
content: var(--i18n-warning, 'Warning');
368382
color: #eab308;
369383
}
384+
370385
.readme :deep(blockquote[data-callout='warning']::after) {
371386
background-color: #eab308;
372387
-webkit-mask: icon('i-lucide:triangle-alert') no-repeat;
@@ -378,10 +393,12 @@ function handleClick(event: MouseEvent) {
378393
border-inline-start-color: #ef4444;
379394
background: rgba(239, 68, 68, 0.05);
380395
}
396+
381397
.readme :deep(blockquote[data-callout='caution']::before) {
382398
content: var(--i18n-caution, 'Caution');
383399
color: #ef4444;
384400
}
401+
385402
.readme :deep(blockquote[data-callout='caution']::after) {
386403
background-color: #ef4444;
387404
-webkit-mask: icon('i-lucide:circle-alert') no-repeat;
@@ -457,4 +474,18 @@ function handleClick(event: MouseEvent) {
457474
white-space: nowrap;
458475
border-width: 0;
459476
}
477+
478+
/* Details element */
479+
.readme :deep(details) {
480+
/**
481+
* same size as [data-level='5']
482+
*/
483+
font-size: 0.925rem;
484+
color: var(--fg-subtle);
485+
486+
summary {
487+
font-size: 1rem;
488+
color: var(--fg-muted);
489+
}
490+
}
460491
</style>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"@iconify-json/svg-spinners": "1.2.4",
5858
"@iconify-json/vscode-icons": "1.2.45",
5959
"@intlify/shared": "11.3.0",
60+
"@li/regexp-escape-polyfill": "jsr:0.3.4",
6061
"@lunariajs/core": "https://pkg.pr.new/lunariajs/lunaria/@lunariajs/core@904b935",
6162
"@napi-rs/canvas": "0.1.97",
6263
"@nuxt/a11y": "1.0.0-alpha.1",

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shared/utils/dev-dependency.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { regExpEscape } from '@li/regexp-escape-polyfill'
2+
13
export type DevDependencySuggestionReason = 'known-package' | 'readme-hint'
24

35
export interface DevDependencySuggestion {
@@ -59,15 +61,11 @@ function isKnownDevDependencyPackage(packageName: string): boolean {
5961
)
6062
}
6163

62-
function escapeRegExp(text: string): string {
63-
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
64-
}
65-
6664
function hasReadmeDevInstallHint(packageName: string, readmeContent?: string | null): boolean {
6765
if (!readmeContent) return false
6866

69-
const escapedName = escapeRegExp(packageName)
70-
const escapedNpmName = escapeRegExp(`npm:${packageName}`)
67+
const escapedName = regExpEscape(packageName)
68+
const escapedNpmName = regExpEscape(`npm:${packageName}`)
7169
const packageSpec = `(?:${escapedName}|${escapedNpmName})(?:@[\\w.-]+)?`
7270

7371
const patterns = [

shared/utils/emoji.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { regExpEscape } from '@li/regexp-escape-polyfill'
2+
13
// copied from https://github.com/markdown-it/markdown-it-emoji/blob/master/lib/data/full.mjs
24
const emojis = {
35
'100': '💯',
@@ -1907,7 +1909,7 @@ const emojis = {
19071909

19081910
const emojisKeysRegex = new RegExp(
19091911
Object.keys(emojis)
1910-
.map(key => `:${key}:`)
1912+
.map(key => `:${regExpEscape(key)}:`)
19111913
.join('|'),
19121914
'g',
19131915
)

test/nuxt/components/Package/Versions.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,21 @@ describe('PackageVersions', () => {
12811281
expect(text).not.toContain('0.5.0')
12821282
})
12831283
})
1284+
1285+
it('does not show latest tag when it does not match the filter', async () => {
1286+
const component = await mountSuspended(PackageVersions, { props: multiVersionProps })
1287+
1288+
const input = component.find('input[type="text"]')
1289+
await input.setValue('^1.0.0 <2.0.0')
1290+
1291+
const versionLinks = component.findAll('a').filter(isVersionLink)
1292+
const versions = versionLinks.map(l => l.text())
1293+
1294+
// 3.0.0 is latest but does NOT match the filter
1295+
expect(versions).not.toContain('3.0.0')
1296+
// 1.0.0 does match
1297+
expect(versions).toContain('1.0.0')
1298+
})
12841299
})
12851300

12861301
describe('error handling', () => {

0 commit comments

Comments
 (0)