Skip to content

Commit 7704005

Browse files
committed
various
1 parent d399a39 commit 7704005

File tree

9 files changed

+126
-43
lines changed

9 files changed

+126
-43
lines changed

apps/svelte.dev/src/routes/content.json/+server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async function content() {
3131

3232
for (const document of docs) {
3333
const { slug, body, metadata } = document;
34-
const breadcrumbs = document.breadcrumbs.map((x) => x.title);
34+
const breadcrumbs = document.breadcrumbs.map((x) => removeMarkdown(x.title));
3535

3636
const sections = body.trim().split(/^## /m);
3737
const intro = sections?.shift()?.trim()!;
Lines changed: 20 additions & 0 deletions
Loading
Lines changed: 20 additions & 0 deletions
Loading
Lines changed: 23 additions & 0 deletions
Loading
Lines changed: 23 additions & 0 deletions
Loading

packages/site-kit/src/lib/search/SearchResultList.svelte

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@
4343
</summary>
4444
<ul>
4545
{#each group.blocks as block (block.href)}
46-
<a href={block.href} onclick={() => onselect?.(block.href)}>
47-
<strong>{@html block.breadcrumbs.slice(2).join('')}</strong>
46+
<a
47+
class:fragment={block.breadcrumbs.length > 4}
48+
href={block.href}
49+
onclick={() => onselect?.(block.href)}
50+
>
51+
<strong>{block.breadcrumbs.slice(2).join('')}</strong>
4852

4953
{#if block?.content}
5054
<div class="excerpt">
@@ -106,10 +110,35 @@
106110
display: block;
107111
text-decoration: none;
108112
line-height: 1;
109-
padding: 1rem;
113+
padding: 1rem 1rem 1rem 5rem;
110114
overflow: hidden;
111115
background: var(--background);
112116
117+
&::before {
118+
content: '';
119+
position: absolute;
120+
width: 5rem;
121+
top: 0;
122+
left: 0;
123+
height: 100%;
124+
background: url(../icons/document-light.svg) no-repeat 50% 50%;
125+
background-size: 2rem;
126+
}
127+
128+
&.fragment::before {
129+
background-image: url(../icons/hash-light.svg);
130+
}
131+
132+
:root.dark & {
133+
&::before {
134+
background-image: url(../icons/document-dark.svg);
135+
}
136+
137+
&.fragment::before {
138+
background-image: url(../icons/hash-dark.svg);
139+
}
140+
}
141+
113142
&:hover {
114143
--background: var(--sk-back-4);
115144
}
@@ -144,8 +173,7 @@
144173
width: calc(100% + 1.4rem);
145174
left: -0.7rem;
146175
overflow: hidden;
147-
color: var(--sk-text-4);
148-
opacity: 0.7;
176+
color: var(--sk-text-1);
149177
150178
&::before,
151179
&::after {
@@ -167,6 +195,10 @@
167195
background: linear-gradient(to right, transparent, var(--background));
168196
}
169197
198+
span {
199+
color: var(--sk-text-3);
200+
}
201+
170202
:global(.spacer) {
171203
display: inline-block;
172204
width: 0.7rem;
@@ -178,7 +210,6 @@
178210
font-size: var(--sk-text-xs);
179211
color: #737373;
180212
margin: 0.4rem 0 0 0;
181-
/* font-family: var(--sk-font-body); */
182213
}
183214
184215
:global(mark) {

packages/site-kit/src/lib/search/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ export { default as Search } from './Search.svelte';
22
export { default as SearchBox } from './SearchBox.svelte';
33
export { default as SearchResults } from './SearchResults.svelte';
44
export { init, inited, lookup, search } from './search';
5-
export type { Block, Tree } from './types';
5+
export type { Block } from './types';

packages/site-kit/src/lib/search/search.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import flexsearch, { type Index as FlexSearchIndex } from 'flexsearch';
2-
import type { Block, BlockGroup, Tree } from './types';
2+
import type { Block, BlockGroup } from './types';
33

44
// @ts-expect-error
55
const Index = (flexsearch.Index as FlexSearchIndex) ?? flexsearch;
@@ -84,10 +84,6 @@ export function search(query: string): BlockGroup[] {
8484
}
8585

8686
return Object.values(groups);
87-
88-
// const results = tree([], blocks).children;
89-
90-
return blocks;
9187
}
9288

9389
/**
@@ -96,26 +92,3 @@ export function search(query: string): BlockGroup[] {
9692
export function lookup(href: string) {
9793
return map.get(href);
9894
}
99-
100-
function tree(breadcrumbs: string[], blocks: Block[]): Tree {
101-
const depth = breadcrumbs.length;
102-
103-
const node = blocks.find((block) => {
104-
if (block.breadcrumbs.length !== depth) return false;
105-
return breadcrumbs.every((part, i) => block.breadcrumbs[i] === part);
106-
});
107-
108-
const descendants = blocks.filter((block) => {
109-
if (block.breadcrumbs.length <= depth) return false;
110-
return breadcrumbs.every((part, i) => block.breadcrumbs[i] === part);
111-
});
112-
113-
const child_parts = Array.from(new Set(descendants.map((block) => block.breadcrumbs[depth])));
114-
115-
return {
116-
breadcrumbs,
117-
href: hrefs.get(breadcrumbs.join('::'))!,
118-
node: node!,
119-
children: child_parts.map((part) => tree([...breadcrumbs, part], descendants))
120-
};
121-
}

packages/site-kit/src/lib/search/types.d.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,3 @@ export interface BlockGroup {
99
breadcrumbs: string[];
1010
blocks: Block[];
1111
}
12-
13-
export interface Tree {
14-
breadcrumbs: string[];
15-
href: string;
16-
node: Block;
17-
children: Tree[];
18-
}

0 commit comments

Comments
 (0)