Skip to content

Commit

Permalink
upgrading Algolia search to latest version. Fixes #443. Fixes #490
Browse files Browse the repository at this point in the history
  • Loading branch information
jwoertink committed Jan 7, 2022
1 parent d581682 commit 436efa2
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 22 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"license": "UNLICENSED",
"private": true,
"dependencies": {
"@docsearch/js": "^3.0.0-alpha.42",
"highlight.js": "^11.4.0",
"modern-normalize": "^1.1.0",
"rails-ujs": "^5.2.6",
Expand Down
20 changes: 1 addition & 19 deletions src/components/shared/header.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class Shared::Header < BaseComponent
nav id: "nav-links", class: "hidden w-full flex-grow md:flex md:flex-grow-0 md:w-auto mt-6 md:mt-0 justify-between items-center font-semibold" do
nav_links
docsearch_input
docsearch_js
end
end

Expand Down Expand Up @@ -62,24 +61,7 @@ class Shared::Header < BaseComponent

private def docsearch_input
div class: "mx-5 md:m-0 header-search" do
input id: "algolia-docsearch",
type: "text",
placeholder: "Search...",
class: "w-full md:w-32 my-6 mr-6 md:m-0 md:mx-0 py-2 px-4 bg-blue-darker appearance-none border-2 border-grey-dark rounded-full transition-base text-white leading-tight focus:text-black md:focus:w-48 focus:shadow-inner focus:outline-none focus:bg-white focus:border-teal"
img src: asset("icons/search.svg")
end
end

private def docsearch_js
script type: "text/javascript" do
raw <<-JS
window.docsearch({
apiKey: '576424427b2189ea2d57cc245beaa67c',
indexName: 'luckyframework',
inputSelector: '#algolia-docsearch',
debug: false // Set debug to true if you want to inspect the dropdown
});
JS
div id: "docsearch"
end
end

Expand Down
3 changes: 1 addition & 2 deletions src/components/shared/layout_head.cr
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class Shared::LayoutHead < BaseComponent
open_graph_tags

script src: "https://buttons.github.io/buttons.js", attrs: [:async, :defer]
css_link "https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css"
script src: "https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"
tag("link", rel: "preconnect", href: "https://P30IY9NAHF-dsn.algolia.net", attrs: [:crossorigin])
end
end

Expand Down
13 changes: 12 additions & 1 deletion src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,15 @@ document.addEventListener("turbolinks:load", function () {
document.querySelectorAll('pre code').forEach((block) => {
hljs.highlightBlock(block);
});
})
});

import docsearch from '@docsearch/js';
import '@docsearch/css';

docsearch({
container: '#docsearch',
appId: 'P30IY9NAHF',
indexName: 'luckyframework',
apiKey: '5d744498cfdcf4d4340dc3751c5bfd5f',
});

171 changes: 171 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,129 @@
# yarn lockfile v1


"@algolia/autocomplete-core@1.5.0":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-core/-/autocomplete-core-1.5.0.tgz#6c91c9de7748e9c103846828a58dfe92bd4d6689"
integrity sha512-E7+VJwcvwMM8vPeaVn7fNUgix8WHV8A1WUeHDi2KHemCaaGc8lvUnP3QnvhMxiDhTe7OpMEv4o2TBUMyDgThaw==
dependencies:
"@algolia/autocomplete-shared" "1.5.0"

"@algolia/autocomplete-preset-algolia@1.5.0":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.5.0.tgz#61671f09c0c77133d9baf1356719f8378c48437a"
integrity sha512-iiFxKERGHkvkiupmrFJbvESpP/zv5jSgH714XRiP5LDvUHaYOo4GLAwZCFf2ef/L5tdtPBARvekn6k1Xf33gjA==
dependencies:
"@algolia/autocomplete-shared" "1.5.0"

"@algolia/autocomplete-shared@1.5.0":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@algolia/autocomplete-shared/-/autocomplete-shared-1.5.0.tgz#09580bc89408a2ab5f29e312120dad68f58019bd"
integrity sha512-bRSkqHHHSwZYbFY3w9hgMyQRm86Wz27bRaGCbNldLfbk0zUjApmE4ajx+ZCVSLqxvcUEjMqZFJzDsder12eKsg==

"@algolia/cache-browser-local-storage@4.12.0":
version "4.12.0"
resolved "https://registry.yarnpkg.com/@algolia/cache-browser-local-storage/-/cache-browser-local-storage-4.12.0.tgz#1f873e4f28a39d25b0a589ebe8f826509458e1fb"
integrity sha512-l+G560B6N1k0rIcOjTO1yCzFUbg2Zy2HCii9s03e13jGgqduVQmk79UUCYszjsJ5GPJpUEKcVEtAIpP7tjsXVA==
dependencies:
"@algolia/cache-common" "4.12.0"

"@algolia/cache-common@4.12.0":
version "4.12.0"
resolved "https://registry.yarnpkg.com/@algolia/cache-common/-/cache-common-4.12.0.tgz#c1111a4d3e9ba2d52cadb4523152580db0887293"
integrity sha512-2Z8BV+NX7oN7RmmQbLqmW8lfN9aAjOexX1FJjzB0YfKC9ifpi9Jl4nSxlnbU+iLR6QhHo0IfuyQ7wcnucCGCGQ==

"@algolia/cache-in-memory@4.12.0":
version "4.12.0"
resolved "https://registry.yarnpkg.com/@algolia/cache-in-memory/-/cache-in-memory-4.12.0.tgz#f4bdcbf8a6419f0166cfc7ef5594af871741e29e"
integrity sha512-b6ANkZF6vGAo+sYv6g25W5a0u3o6F549gEAgtTDTVA1aHcdWwe/HG/dTJ7NsnHbuR+A831tIwnNYQjRp3/V/Jw==
dependencies:
"@algolia/cache-common" "4.12.0"

"@algolia/client-account@4.12.0":
version "4.12.0"
resolved "https://registry.yarnpkg.com/@algolia/client-account/-/client-account-4.12.0.tgz#b28445b47e2abf81dc76982d16ba8458f5c99521"
integrity sha512-gzXN75ZydNheNXUN3epS+aLsKnB/PHFVlGUUjXL8WHs4lJP3B5FtHvaA/NCN5DsM3aamhuY5p0ff1XIA+Lbcrw==
dependencies:
"@algolia/client-common" "4.12.0"
"@algolia/client-search" "4.12.0"
"@algolia/transporter" "4.12.0"

"@algolia/client-analytics@4.12.0":
version "4.12.0"
resolved "https://registry.yarnpkg.com/@algolia/client-analytics/-/client-analytics-4.12.0.tgz#470f115517256c92a5605ae95762531c7906ec74"
integrity sha512-rO2cZCt00Opk66QBZb7IBGfCq4ZE3EiuGkXssf2Monb5urujy0r8CknK2i7bzaKtPbd2vlvhmLP4CEHQqF6SLQ==
dependencies:
"@algolia/client-common" "4.12.0"
"@algolia/client-search" "4.12.0"
"@algolia/requester-common" "4.12.0"
"@algolia/transporter" "4.12.0"

"@algolia/client-common@4.12.0":
version "4.12.0"
resolved "https://registry.yarnpkg.com/@algolia/client-common/-/client-common-4.12.0.tgz#402395e2cffad89188d76b83615acffb3e45e658"
integrity sha512-fcrFN7FBmxiSyjeu3sF4OnPkC1l7/8oyQ8RMM8CHpVY8cad6/ay35MrfRfgfqdzdFA8LzcBYO7fykuJv0eOqxw==
dependencies:
"@algolia/requester-common" "4.12.0"
"@algolia/transporter" "4.12.0"

"@algolia/client-personalization@4.12.0":
version "4.12.0"
resolved "https://registry.yarnpkg.com/@algolia/client-personalization/-/client-personalization-4.12.0.tgz#09c89c1558a91db3bfa60d17f7258ae63861352b"
integrity sha512-wCJfSQEmX6ZOuJBJGjy+sbXiW0iy7tMNAhsVMV9RRaJE4727e5WAqwFWZssD877WQ74+/nF/VyTaB1+wejo33Q==
dependencies:
"@algolia/client-common" "4.12.0"
"@algolia/requester-common" "4.12.0"
"@algolia/transporter" "4.12.0"

"@algolia/client-search@4.12.0":
version "4.12.0"
resolved "https://registry.yarnpkg.com/@algolia/client-search/-/client-search-4.12.0.tgz#ac099ee9f8de85ec204d840bcac734224c7d150c"
integrity sha512-ik6dswcTQtOdZN+8aKntI9X2E6Qpqjtyda/+VANiHThY9GD2PBXuNuuC2HvlF26AbBYp5xaSE/EKxn1DIiIJ4Q==
dependencies:
"@algolia/client-common" "4.12.0"
"@algolia/requester-common" "4.12.0"
"@algolia/transporter" "4.12.0"

"@algolia/logger-common@4.12.0":
version "4.12.0"
resolved "https://registry.yarnpkg.com/@algolia/logger-common/-/logger-common-4.12.0.tgz#0f9dbe7ace88194b395a2cb958490eb47ac91f8e"
integrity sha512-V//9rzLdJujA3iZ/tPhmKR/m2kjSZrymxOfUiF3024u2/7UyOpH92OOCrHUf023uMGYHRzyhBz5ESfL1oCdh7g==

"@algolia/logger-console@4.12.0":
version "4.12.0"
resolved "https://registry.yarnpkg.com/@algolia/logger-console/-/logger-console-4.12.0.tgz#a40edeb989bf0d7ff79d989171dad64cd0f01225"
integrity sha512-pHvoGv53KXRIJHLk9uxBwKirwEo12G9+uo0sJLWESThAN3v5M+ycliU1AkUXQN8+9rds2KxfULAb+vfyfBKf8A==
dependencies:
"@algolia/logger-common" "4.12.0"

"@algolia/requester-browser-xhr@4.12.0":
version "4.12.0"
resolved "https://registry.yarnpkg.com/@algolia/requester-browser-xhr/-/requester-browser-xhr-4.12.0.tgz#64e8e4d4f0724e477421454215195400351cfe61"
integrity sha512-rGlHNMM3jIZBwSpz33CVkeXHilzuzHuFXEEW1icP/k3KW7kwBrKFJwBy42RzAJa5BYlLsTCFTS3xkPhYwTQKLg==
dependencies:
"@algolia/requester-common" "4.12.0"

"@algolia/requester-common@4.12.0":
version "4.12.0"
resolved "https://registry.yarnpkg.com/@algolia/requester-common/-/requester-common-4.12.0.tgz#b4d96f3cbd73206b6042e523d414a34cc005c2e2"
integrity sha512-qgfdc73nXqpVyOMr6CMTx3nXvud9dP6GcMGDqPct+fnxogGcJsp24cY2nMqUrAfgmTJe9Nmy7Lddv0FyHjONMg==

"@algolia/requester-node-http@4.12.0":
version "4.12.0"
resolved "https://registry.yarnpkg.com/@algolia/requester-node-http/-/requester-node-http-4.12.0.tgz#8d8e1b67edbaec8e8e8b8c7c606945b969667267"
integrity sha512-mOTRGf/v/dXshBoZKNhMG00ZGxoUH9QdSpuMKYnuWwIgstN24uj3DQx+Ho3c+uq0TYfq7n2v71uoJWuiW32NMQ==
dependencies:
"@algolia/requester-common" "4.12.0"

"@algolia/transporter@4.12.0":
version "4.12.0"
resolved "https://registry.yarnpkg.com/@algolia/transporter/-/transporter-4.12.0.tgz#e375e10731df95f1be3593b32e86b5c6452cc213"
integrity sha512-MOQVHZ4BcBpf3LtOY/3fqXHAcvI8MahrXDHk9QrBE/iGensQhDiZby5Dn3o2JN/zd9FMnVbdPQ8gnkiMwZiakQ==
dependencies:
"@algolia/cache-common" "4.12.0"
"@algolia/logger-common" "4.12.0"
"@algolia/requester-common" "4.12.0"

"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13":
version "7.12.13"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.13.tgz#dcfc826beef65e75c50e21d3837d7d95798dd658"
Expand Down Expand Up @@ -1033,6 +1156,29 @@
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.2.tgz#8f03a22a04de437254e8ce8cc84ba39689288752"
integrity sha512-HyYEUDeIj5rRQU2Hk5HTB2uHsbRQpF70nvMhVzi+VJR0X+xNEhjPui4/kBf3VeH/wqD28PT4sVOm8qqLjBrSZg==

"@docsearch/css@3.0.0-alpha.42":
version "3.0.0-alpha.42"
resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-3.0.0-alpha.42.tgz#deb6049e999d6ca9451eba4793cb5b6da28c8773"
integrity sha512-AGwI2AXUacYhVOHmYnsXoYDJKO6Ued2W+QO80GERbMLhC7GH5tfvtW5REs/s7jSdcU3vzFoxT8iPDBCh/PkrlQ==

"@docsearch/js@^3.0.0-alpha.42":
version "3.0.0-alpha.42"
resolved "https://registry.yarnpkg.com/@docsearch/js/-/js-3.0.0-alpha.42.tgz#3cef648da141994c8bb1d0f13afbdb0a1e9d8daa"
integrity sha512-8rxxsvFKS5GzDX2MYMETeib4EOwAkoxVUHFP5R4tSENXojhuCEy3np+k3Q0c9WPT+MUmWLxKJab5jyl0jmaeBQ==
dependencies:
"@docsearch/react" "3.0.0-alpha.42"
preact "^10.0.0"

"@docsearch/react@3.0.0-alpha.42":
version "3.0.0-alpha.42"
resolved "https://registry.yarnpkg.com/@docsearch/react/-/react-3.0.0-alpha.42.tgz#1d22a2b05779f24d090ff8d7ff2699e4d50dff5c"
integrity sha512-1aOslZJDxwUUcm2QRNmlEePUgL8P5fOAeFdOLDMctHQkV2iTja9/rKVbkP8FZbIUnZxuuCCn8ErLrjD/oXWOag==
dependencies:
"@algolia/autocomplete-core" "1.5.0"
"@algolia/autocomplete-preset-algolia" "1.5.0"
"@docsearch/css" "3.0.0-alpha.42"
algoliasearch "^4.0.0"

"@nodelib/fs.scandir@2.1.4":
version "2.1.4"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz#d4b3549a5db5de2683e0c1071ab4f140904bbf69"
Expand Down Expand Up @@ -1447,6 +1593,26 @@ ajv@^8.0.0, ajv@^8.8.0:
require-from-string "^2.0.2"
uri-js "^4.2.2"

algoliasearch@^4.0.0:
version "4.12.0"
resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-4.12.0.tgz#30f2619b6e3a5b79b6aa0f18ab66fbce88240aba"
integrity sha512-fZOMMm+F3Bi5M/MoFIz7hiuyCitJza0Hu+r8Wzz4LIQClC6YGMRq7kT6NNU1fSSoFDSeJIwMfedbbi5G9dJoVQ==
dependencies:
"@algolia/cache-browser-local-storage" "4.12.0"
"@algolia/cache-common" "4.12.0"
"@algolia/cache-in-memory" "4.12.0"
"@algolia/client-account" "4.12.0"
"@algolia/client-analytics" "4.12.0"
"@algolia/client-common" "4.12.0"
"@algolia/client-personalization" "4.12.0"
"@algolia/client-search" "4.12.0"
"@algolia/logger-common" "4.12.0"
"@algolia/logger-console" "4.12.0"
"@algolia/requester-browser-xhr" "4.12.0"
"@algolia/requester-common" "4.12.0"
"@algolia/requester-node-http" "4.12.0"
"@algolia/transporter" "4.12.0"

alphanum-sort@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/alphanum-sort/-/alphanum-sort-1.0.2.tgz#97a1119649b211ad33691d9f9f486a8ec9fbe0a3"
Expand Down Expand Up @@ -4988,6 +5154,11 @@ postcss@^8.1.6, postcss@^8.2.1, postcss@^8.2.15, postcss@^8.4.5:
picocolors "^1.0.0"
source-map-js "^1.0.1"

preact@^10.0.0:
version "10.6.4"
resolved "https://registry.yarnpkg.com/preact/-/preact-10.6.4.tgz#ad12c409ff1b4316158486e0a7b8d43636f7ced8"
integrity sha512-WyosM7pxGcndU8hY0OQlLd54tOU+qmG45QXj2dAYrL11HoyU/EzOSTlpJsirbBr1QW7lICxSsVJJmcmUglovHQ==

pretty-hrtime@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1"
Expand Down

0 comments on commit 436efa2

Please sign in to comment.