diff --git a/public/404.svg b/public/404.svg
new file mode 100644
index 00000000..3cbeb710
--- /dev/null
+++ b/public/404.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/components/site/SiteLayout.tsx b/src/components/site/SiteLayout.tsx
index 0f6f855d..41e435aa 100644
--- a/src/components/site/SiteLayout.tsx
+++ b/src/components/site/SiteLayout.tsx
@@ -13,11 +13,16 @@ import { IS_PROD } from "~/lib/constants"
export type SiteLayoutProps = {
children: React.ReactNode
title?: string | null
+ siteId?: string
}
-export const SiteLayout: React.FC = ({ children, title }) => {
+export const SiteLayout: React.FC = ({
+ children,
+ title,
+ siteId,
+}) => {
const router = useRouter()
- const domainOrSubdomain = router.query.site as string
+ const domainOrSubdomain = (router.query.site || siteId) as string
const pageSlug = router.query.page as string
const tag = router.query.tag as string
@@ -54,16 +59,18 @@ export const SiteLayout: React.FC = ({ children, title }) => {
image={page.data?.cover || getUserContentsUrl(site.data?.avatars?.[0])}
icon={getUserContentsUrl(site.data?.avatars?.[0])}
/>
-
+ {site.data && }
{children}
-
-
-
+ {site.data && (
+
+
+
+ )}
>
)
diff --git a/src/markdown/index.ts b/src/markdown/index.ts
index bf3e0d35..9626032b 100644
--- a/src/markdown/index.ts
+++ b/src/markdown/index.ts
@@ -144,7 +144,9 @@ export const renderPageContent = (
.processSync(content)
contentHTML = result.toString()
- } catch (error) {}
+ } catch (error) {
+ console.error(error)
+ }
return {
contentHTML,
element: result?.result,
diff --git a/src/markdown/rehype-image.ts b/src/markdown/rehype-image.ts
index dadd4958..2e0cf4e7 100644
--- a/src/markdown/rehype-image.ts
+++ b/src/markdown/rehype-image.ts
@@ -4,6 +4,7 @@ import { visit } from "unist-util-visit"
import { getUserContentsUrl } from "~/lib/user-contents"
import { toGateway } from "~/lib/ipfs-parser"
import { MarkdownEnv } from "."
+import { IS_PROD } from "~/lib/constants"
const isExternLink = (url: string) => /^https?:\/\//.test(url)
@@ -31,7 +32,7 @@ export const rehypeImage: Plugin, Root> = ({
}
if (isExternLink(url)) {
- if (!url.startsWith("https:")) {
+ if (!url.startsWith("https:") && IS_PROD) {
throw new Error(`External image url must start with https`)
}
return
diff --git a/src/pages/404.tsx b/src/pages/404.tsx
new file mode 100644
index 00000000..31f88583
--- /dev/null
+++ b/src/pages/404.tsx
@@ -0,0 +1,41 @@
+import { useRouter } from "next/router"
+import { SitePage } from "~/components/site/SitePage"
+import { SITE_URL } from "~/lib/env"
+import { SiteLayout } from "~/components/site/SiteLayout"
+import { useState } from "react"
+
+export default function Custom404() {
+ const router = useRouter()
+
+ const [siteId, setSiteId] = useState("")
+
+ try {
+ fetch(`/api/host2handle?host=${window.location.host}`)
+ .then((res) => res.json())
+ .then((tenant) => {
+ if (tenant.subdomain) {
+ setSiteId(tenant.subdomain)
+ }
+ })
+ } catch (error) {}
+
+ return (
+
+
+
+ )
+}