diff --git a/api/ssr.js b/api/ssr.js
index 567e5a2f..4a9d60d0 100644
--- a/api/ssr.js
+++ b/api/ssr.js
@@ -5,7 +5,14 @@ export default async function handler(req, res) {
const pageContext = await renderPage({ urlOriginal: url, cookies })
- const { httpResponse } = pageContext
+ const { httpResponse, errorWhileRendering } = pageContext
+
+ if (errorWhileRendering) {
+ console.error(errorWhileRendering)
+ res.statusCode = 500
+ res.end()
+ return
+ }
if (!httpResponse) {
res.statusCode = 200
diff --git a/src/components/Article/FullArticle.tsx b/src/components/Article/FullArticle.tsx
index 9cd0f253..2d9e8499 100644
--- a/src/components/Article/FullArticle.tsx
+++ b/src/components/Article/FullArticle.tsx
@@ -232,7 +232,7 @@ export const FullArticle = (props: Props) => {
-
+
diff --git a/src/components/Editor/Editor.tsx b/src/components/Editor/Editor.tsx
index adddf04b..64cc75b5 100644
--- a/src/components/Editor/Editor.tsx
+++ b/src/components/Editor/Editor.tsx
@@ -248,7 +248,7 @@ export const Editor = (props: Props) => {
<>
(editorElRef.current = el)} id="editorBody" />
-
+
{
@@ -32,21 +33,34 @@ export const TableOfContents = (props: Props) => {
const [headings, setHeadings] = createSignal([])
const [areHeadingsLoaded, setAreHeadingsLoaded] = createSignal(false)
- const [isVisible, setIsVisible] = createSignal(true)
+ const [isVisible, setIsVisible] = createSignal(props.variant === 'article')
const toggleIsVisible = () => {
setIsVisible((visible) => !visible)
}
- onMount(() => {
+ const updateHeadings = () => {
const { parentSelector } = props
+
// eslint-disable-next-line unicorn/prefer-spread
setHeadings(Array.from(document.querySelector(parentSelector).querySelectorAll('h2, h3, h4')))
-
setAreHeadingsLoaded(true)
- })
+ }
+
+ const debouncedUpdateHeadings = debounce(updateHeadings, 500)
+
+ createEffect(
+ on(
+ () => props.body,
+ () => debouncedUpdateHeadings()
+ )
+ )
return (
-
+ 2 : headings().length > 1)
+ }
+ >