Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Apr 19, 2024
1 parent fb8d99a commit 7217c03
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/langs/json/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions src/lib/api/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type Status = "success" | "readable" | "pending" | "error" | "nofile"; //

export type Sizes = "thumbnail" | "small" | "normal" | "large" | "xlarge";

export type Highlight = Record<string, string[]>;
export type Highlights = Record<string, string[]>;

type AddOnCategory = "premium" | string;

Expand Down Expand Up @@ -122,8 +122,8 @@ export interface Document {
sections?: Section[];

// present in search results when query includes hl=true
highlights?: Highlight;
note_highlights?: Record<string, Highlight[]>;
highlights?: Highlights;
note_highlights?: Record<string, Highlights[]>;
}

export interface DocumentResults extends Page<Document> {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<script lang="ts">
import type { Document, Highlight } from "$lib/api/types";
import type { Document, Highlights } from "$lib/api/types";
import { _ } from "svelte-i18n";
import { pageUrl } from "$lib/api/documents";
/*
Expand All @@ -9,7 +12,7 @@
]
}
*/
export let highlight: Highlight;
export let highlights: Highlights;
export let document: Document;
const PAGE_NO_RE = /^page_no_(\d+)$/;
Expand All @@ -23,9 +26,9 @@
}
</script>

{#each Object.entries(highlight) as [page, segments]}
{#each Object.entries(highlights) as [page, segments]}
{@const [number, href] = pageLink(page)}
<h4><a {href}>Page {number}</a></h4>
<h4><a {href}>{$_("document.page")} {number}</a></h4>
<blockquote class="highlight">
{#each segments as segment}
<p class="segment">{@html segment}</p>
Expand All @@ -36,5 +39,6 @@
<style>
.segment :global(em) {
background-color: var(--yellow);
font-style: normal;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
};
</script>

<Story name="default">
<SearchHighlight {document} {highlight} />
<SearchHighlights {document} {highlights} />
</Story>

0 comments on commit 7217c03

Please sign in to comment.