From 7217c03f7ca1e0d1f1563cbd92a2d03fae938321 Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Fri, 19 Apr 2024 16:26:29 -0400 Subject: [PATCH] rename --- src/langs/json/en.json | 1 + src/lib/api/types.d.ts | 6 +++--- ...earchHighlight.svelte => SearchHighlights.svelte} | 12 ++++++++---- .../stories/SearchHighlights.stories.svelte | 10 +++++----- 4 files changed, 17 insertions(+), 12 deletions(-) rename src/lib/components/documents/{SearchHighlight.svelte => SearchHighlights.svelte} (74%) diff --git a/src/langs/json/en.json b/src/langs/json/en.json index f865addc1..59f69898b 100644 --- a/src/langs/json/en.json +++ b/src/langs/json/en.json @@ -438,6 +438,7 @@ "totalMatchingPages": "{n} of {m} pages matching the query", "showAll": "Show all", "matchingPages": "{n} pages matching the query", + "page": "Page", "pageAbbrev": "p.", "pageCount": "{n, plural, one {# page} other {# pages}}", "source": "Source", diff --git a/src/lib/api/types.d.ts b/src/lib/api/types.d.ts index 28ce6be3e..d0beb2578 100644 --- a/src/lib/api/types.d.ts +++ b/src/lib/api/types.d.ts @@ -17,7 +17,7 @@ export type Status = "success" | "readable" | "pending" | "error" | "nofile"; // export type Sizes = "thumbnail" | "small" | "normal" | "large" | "xlarge"; -export type Highlight = Record; +export type Highlights = Record; type AddOnCategory = "premium" | string; @@ -122,8 +122,8 @@ export interface Document { sections?: Section[]; // present in search results when query includes hl=true - highlights?: Highlight; - note_highlights?: Record; + highlights?: Highlights; + note_highlights?: Record; } export interface DocumentResults extends Page {} diff --git a/src/lib/components/documents/SearchHighlight.svelte b/src/lib/components/documents/SearchHighlights.svelte similarity index 74% rename from src/lib/components/documents/SearchHighlight.svelte rename to src/lib/components/documents/SearchHighlights.svelte index 2b433bffd..84949629c 100644 --- a/src/lib/components/documents/SearchHighlight.svelte +++ b/src/lib/components/documents/SearchHighlights.svelte @@ -1,5 +1,8 @@ -{#each Object.entries(highlight) as [page, segments]} +{#each Object.entries(highlights) as [page, segments]} {@const [number, href] = pageLink(page)} -

Page {number}

+

{$_("document.page")} {number}

{#each segments as segment}

{@html segment}

@@ -36,5 +39,6 @@ diff --git a/src/lib/components/documents/stories/SearchHighlights.stories.svelte b/src/lib/components/documents/stories/SearchHighlights.stories.svelte index 57ea3d6bd..e556009de 100644 --- a/src/lib/components/documents/stories/SearchHighlights.stories.svelte +++ b/src/lib/components/documents/stories/SearchHighlights.stories.svelte @@ -2,22 +2,22 @@ import type { Document } from "$lib/api/types"; import { Story } from "@storybook/addon-svelte-csf"; - import SearchHighlight from "../SearchHighlight.svelte"; + import SearchHighlights from "../SearchHighlights.svelte"; import search from "$lib/api/fixtures/documents/search-highlight.json"; // find one document with highlights const document = search.results.find((d) => d.id === "3913417") as Document; - const highlight = document.highlights; + const highlights = document.highlights; export const meta = { - title: "Components / Documents / Search Highlight", - component: highlight, + title: "Components / Documents / Search Highlights", + component: highlights, tags: ["autodocs"], parameters: { layout: "centered" }, }; - +