From 9765f0540290861db666549743a9c8d48e8b3582 Mon Sep 17 00:00:00 2001 From: Liam Bigelow <40188355+bglw@users.noreply.github.com> Date: Thu, 16 Nov 2023 09:32:24 +1300 Subject: [PATCH] Revert highlight impl in the Default UI in prep of moving to JS API --- pagefind_ui/default/svelte/result.svelte | 291 +++++++++--------- .../default/svelte/result_with_subs.svelte | 24 +- 2 files changed, 156 insertions(+), 159 deletions(-) diff --git a/pagefind_ui/default/svelte/result.svelte b/pagefind_ui/default/svelte/result.svelte index 86639611..e1fca739 100644 --- a/pagefind_ui/default/svelte/result.svelte +++ b/pagefind_ui/default/svelte/result.svelte @@ -1,155 +1,162 @@
  • - {#if data} - {#if show_images} -
    - {#if data.meta.image} - {data.meta?.image_alt + {#if data} + {#if show_images} +
    + {#if data.meta.image} + {data.meta?.image_alt + {/if} +
    {/if} -
    - {/if} -
    -

    - {@html data.meta?.title} -

    -

    {@html data.excerpt}

    - {#if meta.length} - - {/if} -
    - {:else} - {#if show_images} -
    +
    +

    + {data.meta?.title} +

    +

    {@html data.excerpt}

    + {#if meta.length} +
      + {#each meta as [metaTitle, metaValue]} +
    • + {metaTitle.replace(/^(\w)/, (c) => + c.toLocaleUpperCase() + )}: {metaValue} +
    • + {/each} +
    + {/if} +
    + {:else} + {#if show_images} +
    + {/if} +
    +

    + {placeholder(30)} +

    +

    + {placeholder(40)} +

    +
    {/if} -
    -

    - {placeholder(30)} -

    -

    - {placeholder(40)} -

    -
    - {/if}
  • diff --git a/pagefind_ui/default/svelte/result_with_subs.svelte b/pagefind_ui/default/svelte/result_with_subs.svelte index 5ee77ee9..1f16885e 100644 --- a/pagefind_ui/default/svelte/result_with_subs.svelte +++ b/pagefind_ui/default/svelte/result_with_subs.svelte @@ -2,8 +2,6 @@ export let show_images = true; export let process_result = null; export let result = { data: async () => {} }; - // string or null - export let highlight_query_param = null; const skipMeta = ["title", "image", "image_alt", "url"]; @@ -28,12 +26,10 @@ const load = async (r) => { data = await r.data(); data = process_result?.(data) ?? data; - meta = Object.entries(data?.meta).filter( - ([key]) => !skipMeta.includes(key) - ); + meta = Object.entries(data.meta).filter(([key]) => !skipMeta.includes(key)); if (Array.isArray(data.sub_results)) { has_root_sub_result = - data.sub_results?.[0]?.url === (data?.meta?.url || data?.url); + data.sub_results?.[0]?.url === (data.meta?.url || data.url); if (has_root_sub_result) { non_root_sub_results = thin_sub_results(data.sub_results.slice(1), 3); } else { @@ -63,11 +59,8 @@ {/if}

    - {@html data.meta?.title}{data.meta?.title}

    {#if has_root_sub_result} @@ -77,11 +70,8 @@ {#each non_root_sub_results as subres}

    - {@html subres.title}{subres.title}

    {@html subres.excerpt}

    @@ -92,7 +82,7 @@