diff --git a/apps/landing/global.d.ts b/apps/landing/global.d.ts
index bc4a25e68..2378c3a15 100644
--- a/apps/landing/global.d.ts
+++ b/apps/landing/global.d.ts
@@ -1,3 +1,5 @@
+///
+
/* eslint-disable @typescript-eslint/no-empty-object-type */
/* eslint-disable @typescript-eslint/method-signature-style */
import type { FC, PropsWithChildren } from 'react'
diff --git a/apps/landing/src/app/[locale]/privacy-policy/page.tsx b/apps/landing/src/app/[locale]/privacy-policy/page.tsx
index a9e60ec30..42233aa70 100644
--- a/apps/landing/src/app/[locale]/privacy-policy/page.tsx
+++ b/apps/landing/src/app/[locale]/privacy-policy/page.tsx
@@ -1,6 +1,7 @@
import type { Metadata } from 'next/types'
-import { getMarkdownContent, MarkdownContent } from '~/components/ui/markdown'
+import { MarkdownContent } from '~/components/ui/markdown'
+import { getMarkdownContent } from '~/components/ui/markdown/get-markdown-content'
import { siteInfo } from '~/constants/site'
export const metadata: Metadata = {
diff --git a/apps/landing/src/app/[locale]/terms-of-service/page.tsx b/apps/landing/src/app/[locale]/terms-of-service/page.tsx
index 347469b27..2b8f33626 100644
--- a/apps/landing/src/app/[locale]/terms-of-service/page.tsx
+++ b/apps/landing/src/app/[locale]/terms-of-service/page.tsx
@@ -1,6 +1,7 @@
import type { Metadata } from 'next/types'
-import { getMarkdownContent, MarkdownContent } from '~/components/ui/markdown'
+import { MarkdownContent } from '~/components/ui/markdown'
+import { getMarkdownContent } from '~/components/ui/markdown/get-markdown-content'
import { siteInfo } from '~/constants/site'
export const metadata: Metadata = {
diff --git a/apps/landing/src/components/ui/markdown/get-markdown-content.ts b/apps/landing/src/components/ui/markdown/get-markdown-content.ts
new file mode 100644
index 000000000..7f02decba
--- /dev/null
+++ b/apps/landing/src/components/ui/markdown/get-markdown-content.ts
@@ -0,0 +1,35 @@
+import rehypeStringify from 'rehype-stringify'
+import remarkParse from 'remark-parse'
+import remarkRehype from 'remark-rehype'
+import { unified } from 'unified'
+
+import privacyPolicyMarkdown from '~/legal/privacy.md?raw'
+import termsOfServiceMarkdown from '~/legal/tos.md?raw'
+
+const markdownContentByPath = {
+ 'legal/privacy.md': privacyPolicyMarkdown,
+ 'legal/tos.md': termsOfServiceMarkdown,
+} as const
+
+export type MarkdownFilePath = keyof typeof markdownContentByPath
+
+export async function getMarkdownContent(filePath: MarkdownFilePath) {
+ try {
+ const fileContents = markdownContentByPath[filePath]
+
+ const processedContent = await unified()
+ .use(remarkParse)
+ .use(remarkRehype, { allowDangerousHtml: true })
+ .use(rehypeStringify, { allowDangerousHtml: true })
+ .process(fileContents)
+
+ return {
+ content: processedContent.toString(),
+ }
+ } catch (error) {
+ console.error('Error reading markdown file:', error)
+ return {
+ content: '
Error loading content. Please try again later.
',
+ }
+ }
+}
diff --git a/apps/landing/src/components/ui/markdown/index.tsx b/apps/landing/src/components/ui/markdown/index.tsx
index 31275a8dc..470109544 100644
--- a/apps/landing/src/components/ui/markdown/index.tsx
+++ b/apps/landing/src/components/ui/markdown/index.tsx
@@ -1,11 +1,3 @@
-import fs from 'node:fs'
-
-import { join } from 'pathe'
-import rehypeStringify from 'rehype-stringify'
-import remarkParse from 'remark-parse'
-import remarkRehype from 'remark-rehype'
-import { unified } from 'unified'
-
interface MarkdownContentProps {
content: string
}
@@ -25,27 +17,3 @@ export function MarkdownContent({ content }: MarkdownContentProps) {
)
}
-
-// Utility function to read and process markdown files
-export async function getMarkdownContent(filePath: string) {
- try {
- const fullPath = join(process.cwd(), 'src', filePath)
- const fileContents = fs.readFileSync(fullPath, 'utf8')
-
- // Process markdown to HTML using unified
- const processedContent = await unified()
- .use(remarkParse)
- .use(remarkRehype, { allowDangerousHtml: true })
- .use(rehypeStringify, { allowDangerousHtml: true })
- .process(fileContents)
-
- return {
- content: processedContent.toString(),
- }
- } catch (error) {
- console.error('Error reading markdown file:', error)
- return {
- content: 'Error loading content. Please try again later.
',
- }
- }
-}
diff --git a/apps/landing/src/components/ui/markdown/markdown.test.ts b/apps/landing/src/components/ui/markdown/markdown.test.ts
new file mode 100644
index 000000000..2783e4c86
--- /dev/null
+++ b/apps/landing/src/components/ui/markdown/markdown.test.ts
@@ -0,0 +1,19 @@
+import { describe, expect, it } from 'vitest'
+
+import { getMarkdownContent } from './get-markdown-content'
+
+describe('getMarkdownContent', () => {
+ it('renders the privacy policy markdown content', async () => {
+ const { content } = await getMarkdownContent('legal/privacy.md')
+
+ expect(content).toContain('Privacy Policy
')
+ expect(content).not.toContain('Error loading content')
+ })
+
+ it('renders the terms of service markdown content', async () => {
+ const { content } = await getMarkdownContent('legal/tos.md')
+
+ expect(content).toContain('Terms of Service
')
+ expect(content).not.toContain('Error loading content')
+ })
+})