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
13 changes: 11 additions & 2 deletions apps/svelte.dev/src/routes/content.json/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,24 @@ async function plaintext(markdown: string) {

return (
await markedTransform(markdown, {
code: ({ text }) => text.split('// ---cut---\n').pop() || 'ERROR: ---cut--- not found',
code: ({ text }) => {
const raw = text.split('// ---cut---\n').pop() ?? '';

return raw
.replace(/^\/\/ @noErrors.*$/gm, ' ')
.replace(/^\/\/ @errors.+$/gm, ' ')
.replace(/^\/\/\/ file:.+$/gm, ' ');
},
blockquote: block,
html: () => '\n',
heading: ({ text }) => `${text}\n`,
hr: () => '',
list: block,
listitem: block,
checkbox: block,
paragraph: ({ text }) => `${text}\n\n`,
paragraph({ tokens }) {
return this.parser!.parseInline(tokens);
},
table: block,
tablerow: block,
tablecell: ({ text }) => {
Expand Down
131 changes: 71 additions & 60 deletions packages/site-kit/src/lib/search/SearchBox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -160,24 +160,26 @@ It appears when the user clicks on the `Search` component or presses the corresp
use:trap
>
<div class="search-box">
<!-- svelte-ignore a11y_autofocus -->
<input
autofocus
onkeydown={(e) => {
<div style="background: var(--background)">
<!-- svelte-ignore a11y_autofocus -->
<input
autofocus
onkeydown={(e) => {
if (e.key === 'Enter' && !e.isComposing) {
const element = modal.querySelector('a[data-has-node]') as HTMLElement | undefined;
element?.click();
}
}}
oninput={(e) => {
$search_query = e.currentTarget.value;
}}
value={$search_query}
{placeholder}
aria-describedby="search-description"
aria-label={placeholder}
spellcheck="false"
/>
oninput={(e) => {
$search_query = e.currentTarget.value;
}}
value={$search_query}
{placeholder}
aria-describedby="search-description"
aria-label={placeholder}
spellcheck="false"
/>
</div>

<button aria-label="Close" onclick={close}>
<!-- <Icon name="close" /> -->
Expand All @@ -204,18 +206,19 @@ It appears when the user clicks on the `Search` component or presses the corresp
/>
</div>
{:else}
<h2 class="info" class:empty={recent_searches.length === 0}>
<span class="info" class:empty={recent_searches.length === 0}>
{#if idle}
{@render idle(recent_searches.length)}
{:else}
{recent_searches.length ? 'Recent searches' : 'No recent searches'}
{/if}
</h2>
</span>

{#if recent_searches.length}
<div class="results-container">
<ul>
<ul class="recent">
{#each recent_searches as search}
<li class="recent">
<li>
<a onclick={() => navigate(search.href)} href={search.href}>
{search.breadcrumbs.at(-1)}
</a>
Expand Down Expand Up @@ -279,7 +282,7 @@ It appears when the user clicks on the `Search` component or presses the corresp
.search-box {
--padding: 1rem;
--background: var(--sk-back-2);
background: var(--background);
/* background: var(--background); */
position: relative;
height: calc(100% - 2rem);
width: calc(100vw - 2rem);
Expand Down Expand Up @@ -360,59 +363,67 @@ It appears when the user clicks on the `Search` component or presses the corresp
.results-container {
border-radius: 0 0 var(--sk-border-radius) var(--sk-border-radius);
pointer-events: all;
background: var(--background);

li {
position: relative;

a {
color: var(--sk-text-2);
display: block;
text-decoration: none;
padding: 0.5rem calc(4rem + var(--padding)) 0.5rem var(--padding);

&:hover {
background: rgba(0, 0, 0, 0.05);
}

&:focus {
outline-offset: -3px;
}
}

button[aria-label='Delete'] {
position: absolute;
top: 0;
right: 0;
width: 5rem;
height: 100%;
color: var(--sk-text-2);
opacity: 0.1;

&:hover {
opacity: 1;
outline: none;
}

&:focus-visible {
opacity: 1;
outline-offset: -3px;
}
}
}

.recent {
a {
font-size: var(--sk-font-size-ui-medium);
}
}
}

.info {
display: block;
background: var(--background);
padding: var(--padding);
font-family: var(--sk-font-ui);
font-size: var(--sk-font-size-ui-medium);
color: var(--sk-text-4);
font-weight: normal;
text-transform: uppercase;
pointer-events: all;
}

.info.empty {
border-radius: 0 0 var(--sk-border-radius) var(--sk-border-radius);
}

a {
color: var(--sk-text-2);
display: block;
text-decoration: none;
line-height: 1;
padding: 1rem calc(4rem + var(--padding)) 1rem var(--padding);

&:hover {
background: rgba(0, 0, 0, 0.05);
}

&:focus {
outline-offset: -3px;
}
}

li {
position: relative;
}

button[aria-label='Delete'] {
position: absolute;
top: 0;
right: 0;
width: 5rem;
height: 100%;
color: var(--sk-text-2);
opacity: 0.1;

&:hover {
opacity: 1;
outline: none;
}

&:focus-visible {
opacity: 1;
outline-offset: -3px;
&.empty {
border-radius: 0 0 var(--sk-border-radius) var(--sk-border-radius);
}
}
</style>
8 changes: 4 additions & 4 deletions packages/site-kit/src/lib/search/SearchResultList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
}

const prefix =
index > 20
? `${escape(content.slice(index - 15, index))}`
index > 40 && content.length > 70
? `${escape(content.slice(index - 35, index))}`
: `<span class="spacer"></span>${escape(content.slice(0, index))}`;
const suffix = escape(
content.slice(
Expand Down Expand Up @@ -73,7 +73,7 @@
}

details {
padding: 0.5rem 0;
padding: calc(0.5 * var(--padding)) 0;

summary {
position: sticky;
Expand All @@ -82,7 +82,7 @@
display: block;
color: var(--sk-text-4);
text-transform: uppercase;
padding: 0.5rem var(--padding);
padding: calc(0.5 * var(--padding)) var(--padding);
font-size: var(--sk-font-size-ui-medium);
z-index: 2;
user-select: none;
Expand Down
3 changes: 2 additions & 1 deletion packages/site-kit/src/lib/search/SearchResults.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ Renders a list of search results
<style>
.info {
padding: var(--padding);
font-size: 1.2rem;
font-size: var(--sk-font-size-ui-medium);
color: var(--sk-text-4);
font-weight: normal;
text-transform: uppercase;
background-color: var(--sk-back-2);
Expand Down
Loading