diff --git a/src/assets/javascripts/templates/clipboard/index.tsx b/src/assets/javascripts/templates/clipboard/index.tsx index b9b470be9..8e2a28172 100644 --- a/src/assets/javascripts/templates/clipboard/index.tsx +++ b/src/assets/javascripts/templates/clipboard/index.tsx @@ -52,7 +52,7 @@ export function renderClipboard( ) } diff --git a/src/assets/javascripts/templates/search/index.ts b/src/assets/javascripts/templates/search/index.ts deleted file mode 100644 index cda3d7d1b..000000000 --- a/src/assets/javascripts/templates/search/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2016-2020 Martin Donath - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -export * from "./result" diff --git a/src/assets/javascripts/templates/search/result/article/index.tsx b/src/assets/javascripts/templates/search/index.tsx similarity index 70% rename from src/assets/javascripts/templates/search/result/article/index.tsx rename to src/assets/javascripts/templates/search/index.tsx index 4dc56bba0..f6f5c688b 100644 --- a/src/assets/javascripts/templates/search/result/article/index.tsx +++ b/src/assets/javascripts/templates/search/index.tsx @@ -21,7 +21,7 @@ */ import { h } from "extensions" -import { ArticleDocument } from "modules" +import { SearchResult } from "modules" import { truncate } from "utilities" /* ---------------------------------------------------------------------------- @@ -32,8 +32,10 @@ import { truncate } from "utilities" * CSS classes */ const css = { + item: "md-search-result__item", link: "md-search-result__link", article: "md-search-result__article md-search-result__article--document", + section: "md-search-result__article", title: "md-search-result__title", teaser: "md-search-result__teaser" } @@ -43,24 +45,32 @@ const css = { * ------------------------------------------------------------------------- */ /** - * Render an article document + * Render a search result * - * @param article - Article document + * @param result - Search result * * @return HTML element */ -export function renderArticleDocument( - { location, title, text }: ArticleDocument +export function renderSearchResult( + { article, sections }: SearchResult ): HTMLElement { + const children = [article, ...sections].map(document => { + const { location, title, text } = document + return ( + +
+

{title}

+ {text.length + ?

{truncate(text, 320)}

+ : undefined + } +
+
+ ) + }) return ( - -
-

{title}

- {text.length - ?

{truncate(text, 320)}

- : undefined - } -
-
+
  • + {...children} +
  • ) } diff --git a/src/assets/javascripts/templates/search/result/index.ts b/src/assets/javascripts/templates/search/result/index.ts deleted file mode 100644 index 8bf56dec7..000000000 --- a/src/assets/javascripts/templates/search/result/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2016-2020 Martin Donath - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -export * from "./_" diff --git a/src/assets/javascripts/templates/search/result/section/index.tsx b/src/assets/javascripts/templates/search/result/section/index.tsx deleted file mode 100644 index 12ea8f05b..000000000 --- a/src/assets/javascripts/templates/search/result/section/index.tsx +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2016-2020 Martin Donath - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -import { h } from "extensions" -import { SectionDocument } from "modules" -import { truncate } from "utilities" - -/* ---------------------------------------------------------------------------- - * Data - * ------------------------------------------------------------------------- */ - -/** - * CSS classes - */ -const css = { - link: "md-search-result__link", - article: "md-search-result__article", - title: "md-search-result__title", - teaser: "md-search-result__teaser" -} - -/* ---------------------------------------------------------------------------- - * Functions - * ------------------------------------------------------------------------- */ - -/** - * Render a section document - * - * @param section - Section document - * - * @return HTML element - */ -export function renderSectionDocument( - { location, title, text }: SectionDocument -): HTMLElement { - return ( - -
    -

    {title}

    - {text.length - ?

    {truncate(text, 320)}

    - : undefined - } -
    -
    - ) -} diff --git a/src/assets/javascripts/templates/search/result/_/index.tsx b/src/assets/javascripts/templates/table/index.tsx similarity index 79% rename from src/assets/javascripts/templates/search/result/_/index.tsx rename to src/assets/javascripts/templates/table/index.tsx index d293187df..00a254311 100644 --- a/src/assets/javascripts/templates/search/result/_/index.tsx +++ b/src/assets/javascripts/templates/table/index.tsx @@ -21,10 +21,6 @@ */ import { h } from "extensions" -import { SearchResult } from "modules" - -import { renderArticleDocument } from "../article" -import { renderSectionDocument } from "../section" /* ---------------------------------------------------------------------------- * Data @@ -34,7 +30,8 @@ import { renderSectionDocument } from "../section" * CSS classes */ const css = { - item: "md-search-result__item" + wrapper: "md-typeset__scrollwrap", + table: "md-typeset__table" } /* ---------------------------------------------------------------------------- @@ -42,19 +39,20 @@ const css = { * ------------------------------------------------------------------------- */ /** - * Render a search result + * Render a table wrapper * - * @param result - Search result + * @param table - Table element * * @return HTML element */ -export function renderSearchResult( - { article, sections }: SearchResult +export function renderTable( + table: HTMLTableElement ): HTMLElement { return ( -
  • - {renderArticleDocument(article)} - {...sections.map(renderSectionDocument)} -
  • +
    +
    + {table} +
    +
    ) }