From 84234230f926091d19dec50b5812f62c8e42e8d7 Mon Sep 17 00:00:00 2001 From: Max Edell Date: Mon, 16 Oct 2023 15:21:15 -0700 Subject: [PATCH] fix: rm logs, workaround for missing book --- blocks/article/article.js | 4 +++- blocks/search-bar/search-bar.js | 2 -- scripts/scripts.js | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/blocks/article/article.js b/blocks/article/article.js index 92bdefc..af5b273 100644 --- a/blocks/article/article.js +++ b/blocks/article/article.js @@ -392,9 +392,11 @@ async function renderContent(block, res, rerender = false) { const fragment = document.createElement('div'); const docTitle = document.createElement('a'); + // eslint-disable-next-line no-nested-ternary + const titleText = isGdoc ? document.title : store.mainBook ? store.mainBook.title : undefined; docTitle.setAttribute('slot', 'document'); docTitle.href = window.location.href.split('/').slice(0, -2).join('/'); - docTitle.textContent = isGdoc ? document.title : store.mainBook.title; + docTitle.textContent = titleText; fragment.append(docTitle); block.classList.remove(`source-${isGdoc ? 'adoc' : 'gdoc'}`); diff --git a/blocks/search-bar/search-bar.js b/blocks/search-bar/search-bar.js index c6a9c6c..852a726 100644 --- a/blocks/search-bar/search-bar.js +++ b/blocks/search-bar/search-bar.js @@ -296,9 +296,7 @@ export class SearchBar extends HTMLElement { } export default function decorate(block) { - console.log('decorate search-bar: ', block); const config = readBlockConfig(block); - console.log('config: ', config); block.innerHTML = ``; diff --git a/scripts/scripts.js b/scripts/scripts.js index eab000b..d565775 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -25,6 +25,8 @@ polyfill(); const range = document.createRange(); export const BRANCH_ORIGIN = 'https://prisma-cloud-docs-production.adobeaem.workers.dev'; +// export const BRANCH_ORIGIN = 'http://127.0.0.1:3001'; + export const SPA_NAVIGATION = true; export const REDIRECTED_ARTICLE_KEY = 'redirected-article'; export const PATH_PREFIX = ''; @@ -112,7 +114,7 @@ export function siteToDocURL(siteUrl) { */ export function setBranch(url, branch = getBranch(), searchParamOnly = false) { if (branch) { - url.searchParams.append('branch', branch); + url.searchParams.set('branch', branch); if (!searchParamOnly) { const branchURL = new URL(BRANCH_ORIGIN); url.protocol = branchURL.protocol;