Skip to content

Commit

Permalink
Add them links back (#948)
Browse files Browse the repository at this point in the history
* Revert "Replacing turbolinks with turbo. This fixes the issue with the search randomly disappearing. Fixes #917 (#932)"

This reverts commit bb320a8.

# Conflicts:
#	package.json

* Ensure docsearch is loaded on every turbo pageload

This seems to resolve the issue around the searchbox not
being visible in some situations.

* Switch watcher port to 3000 by default

Use of port 5000 has been deprecated in upstream
CLI builds due to its conflicts on OSX. This allows
for local dev in Mac-based environments more easily.
  • Loading branch information
robcole authored Mar 8, 2022
1 parent ed0bf59 commit b594b53
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion config/watch.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
host: 127.0.0.1
port: 5000
port: 3000
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"private": true,
"dependencies": {
"@docsearch/js": "^3.0.0",
"@hotwired/turbo": "^7.1.0",
"@rails/ujs": "^7.0.2-2",
"highlight.js": "^11.4.0",
"modern-normalize": "^1.1.0"
"modern-normalize": "^1.1.0",
"rails-ujs": "^5.2.6",
"turbolinks": "^5.2.0"
},
"scripts": {
"heroku-postbuild": "yarn prod",
Expand Down
4 changes: 2 additions & 2 deletions src/components/shared/layout_head.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class Shared::LayoutHead < BaseComponent
head do
utf8_charset
title "Lucky - #{@seo.page_title}"
css_link asset("css/app.css"), data_turbo_track: "reload"
js_link asset("js/app.js"), defer: "defer", data_turbo_track: "reload"
css_link asset("css/app.css"), data_turbolinks_track: "reload"
js_link asset("js/app.js"), defer: "defer", data_turbolinks_track: "reload"
csrf_meta_tags
meta name: "description", content: @seo.page_description
rss_link
Expand Down
17 changes: 11 additions & 6 deletions src/js/app.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
/* eslint no-console:0 */

// RailsUjs is *required* for links in Lucky that use DELETE, POST and PUT.
require("@rails/ujs").start();
require("@hotwired/turbo");
import RailsUjs from "rails-ujs";

// Turbolinks is optional. Learn more: https://github.com/turbolinks/turbolinks/
import Turbolinks from "turbolinks";

RailsUjs.start();
Turbolinks.start();

import hljs from 'highlight.js/lib/core';

Expand Down Expand Up @@ -39,15 +43,16 @@ hljs.registerLanguage('diff', diff);

import docsearch from '@docsearch/js';

document.addEventListener("turbo:load", function () {
document.querySelectorAll('pre code').forEach((block) => {
hljs.highlightElement(block);
});
document.addEventListener("turbolinks:load", function () {

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

document.querySelectorAll('pre code').forEach((block) => {
hljs.highlightElement(block);
});
});
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1058,11 +1058,6 @@
"@docsearch/css" "3.0.0"
algoliasearch "^4.0.0"

"@hotwired/turbo@^7.1.0":
version "7.1.0"
resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-7.1.0.tgz#27e44e0e3dc5bd1d4bda0766d579cf5a14091cd7"
integrity sha512-Q8kGjqwPqER+CtpQudbH+3Zgs2X4zb6pBAlr6NsKTXadg45pAOvxI9i4QpuHbwSzR2+x87HUm+rot9F/Pe8rxA==

"@jridgewell/resolve-uri@^3.0.3":
version "3.0.5"
resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz#68eb521368db76d040a6315cdb24bf2483037b9c"
Expand Down Expand Up @@ -1102,11 +1097,6 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@rails/ujs@^7.0.2-2":
version "7.0.2-2"
resolved "https://registry.yarnpkg.com/@rails/ujs/-/ujs-7.0.2-2.tgz#9f2f114f4777627034be541151a1240ebe585199"
integrity sha512-2M+stexFdUwVXMo4sborFkGEI7A7qEl8iIZX9oqW/JOjEyl6jpjpKAtPCAvKrXQAduX8lBQKHj/eTQKqONVB0Q==

"@trysound/sax@0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad"
Expand Down Expand Up @@ -4958,6 +4948,11 @@ quick-lru@^5.1.1:
resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932"
integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==

rails-ujs@^5.2.6:
version "5.2.6"
resolved "https://registry.yarnpkg.com/rails-ujs/-/rails-ujs-5.2.6.tgz#4193242a108d0cd9ed3595695644755c0bd329eb"
integrity sha512-JpUq5RlA4p5XE69dz0ZOIkn1xXQn9H8VDXQJWuVPRtFBOFylWFriaDVpxFmdQuARPo4bm2l67uIMMBpX6KNY+g==

randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a"
Expand Down Expand Up @@ -5828,6 +5823,11 @@ tty-browserify@0.0.0:
resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"
integrity sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=

turbolinks@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/turbolinks/-/turbolinks-5.2.0.tgz#e6877a55ea5c1cb3bb225f0a4ae303d6d32ff77c"
integrity sha512-pMiez3tyBo6uRHFNNZoYMmrES/IaGgMhQQM+VFF36keryjb5ms0XkVpmKHkfW/4Vy96qiGW3K9bz0tF5sK9bBw==

type-is@~1.6.18:
version "1.6.18"
resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131"
Expand Down

0 comments on commit b594b53

Please # to comment.