Skip to content

Commit

Permalink
mat review compliance thing
Browse files Browse the repository at this point in the history
  • Loading branch information
stjet committed Jun 19, 2022
1 parent 5189b5d commit dcd088f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/lib/EntryPreview.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@

{#if entry.tags}
{#each entry.tags as tag}
<p
<span
class="tag"
on:click={event => {
setTagSearch({ tag })
event.cancelBubble = true
}}
>
{tag}
</p>
</span>
{/each}
{/if}
</div>
Expand Down
42 changes: 20 additions & 22 deletions src/routes/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@
let showVisible = true
let showUnlisted = false
let showHidden = false
let searchValue = ''
let fetchIndex = 0
async function updateEntries() {
fetchIndex += 1
let thisFetchIndex = fetchIndex
let search_value = (document.getElementById('search') as HTMLInputElement).value || null
let tags: string
let query: string
if (!search_value) {
if (!searchValue) {
query = undefined
} else {
let all = search_value.split(' ')
let all = searchValue.split(' ')
query = all.filter(word => !word.startsWith('tags:')).join(' ')
if (search_value.includes('tags:')) {
if (searchValue.includes('tags:')) {
let tags_raw = all.filter(word => word.startsWith('tags:'))[0]
tags = tags_raw.slice(5).replaceAll('_', '%20')
console.log(query)
Expand All @@ -65,20 +65,7 @@
const res = await fetch(url)
const newEntries = await res.json()
if (newEntries.length === 0) {
entries = [
{
title: 'No Results Found',
content: 'Sorry, there are no results found with that query!',
slug: 'entry_does_not_exist',
id: '0',
tags: ['Error'],
visibility: 'visible',
},
]
} else {
if (thisFetchIndex === fetchIndex) entries = newEntries
}
if (thisFetchIndex === fetchIndex) entries = newEntries
}
$: {
Expand Down Expand Up @@ -121,13 +108,24 @@
{/if}

<div class="searchbar-container">
<input type="text" id="search" class="search" placeholder="Search" on:input={updateEntries} />
<input
type="text"
id="search"
class="search"
placeholder="Search"
bind:value={searchValue}
on:input={updateEntries}
/>
</div>

<div class="entry-list">
{#each entries as entry}
<EntryPreview {entry} />
{/each}
{#if entries.length !== 0}
{#each entries as entry}
<EntryPreview {entry} />
{/each}
{:else}
<p>No entries with query found</p>
{/if}
</div>

<style>
Expand Down

0 comments on commit dcd088f

Please sign in to comment.