config ?
This commit is contained in:
@@ -6,12 +6,7 @@ const nextConfig = {
|
||||
// Ensure we can access the app from outside the container
|
||||
experimental: {
|
||||
outputFileTracingRoot: undefined,
|
||||
},
|
||||
// Configure the hostname and port
|
||||
server: {
|
||||
hostname: '0.0.0.0',
|
||||
port: 8080,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = nextConfig
|
||||
5618
package-lock.json
generated
5618
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
51
package.json
51
package.json
@@ -7,46 +7,35 @@
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"electron-dev": "electron .",
|
||||
"electron-build": "next build && electron-builder"
|
||||
"electron": "electron .",
|
||||
"electron-dev": "concurrently \"npm run dev\" \"npm run electron\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@tailwindcss/typography": "^0.5.16",
|
||||
"@types/dompurify": "^3.0.5",
|
||||
"@types/jsdom": "^21.1.7",
|
||||
"@types/marked": "^5.0.2",
|
||||
"@types/node": "^20.11.24",
|
||||
"@types/react": "^18.2.61",
|
||||
"@types/react-dom": "^18.2.19",
|
||||
"autoprefixer": "^10.4.17",
|
||||
"bcrypt": "^6.0.0",
|
||||
"chokidar": "^4.0.3",
|
||||
"date-fns": "^3.3.1",
|
||||
"dompurify": "^3.2.6",
|
||||
"chokidar": "^3.6.0",
|
||||
"dompurify": "^3.0.9",
|
||||
"electron": "^29.1.0",
|
||||
"gray-matter": "^4.0.3",
|
||||
"jsdom": "^26.1.0",
|
||||
"marked": "^15.0.12",
|
||||
"jsdom": "^24.0.0",
|
||||
"marked": "^12.0.0",
|
||||
"next": "14.1.0",
|
||||
"postcss": "^8.4.35",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"rehype-raw": "^6.1.1",
|
||||
"rehype-sanitize": "^6.0.0",
|
||||
"rehype-stringify": "^9.0.3",
|
||||
"remark": "^15.0.0",
|
||||
"remark-gfm": "^3.0.1",
|
||||
"remark-html": "^16.0.1",
|
||||
"remark-parse": "^11.0.0",
|
||||
"remark-rehype": "^11.0.0",
|
||||
"tailwindcss": "^3.4.1"
|
||||
"tailwindcss": "^3.4.1",
|
||||
"typescript": "^5.3.3",
|
||||
"date-fns": "^3.6.0",
|
||||
"@tailwindcss/typography": "^0.5.16"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bcrypt": "^5.0.2",
|
||||
"@types/chokidar": "^1.7.5",
|
||||
"@types/node": "^20.11.19",
|
||||
"@types/react": "^18.2.57",
|
||||
"@types/react-dom": "^18.2.19",
|
||||
"electron": "^28.2.3",
|
||||
"electron-builder": "^24.9.1",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-config-next": "14.1.0",
|
||||
"typescript": "^5.3.3"
|
||||
"@types/dompurify": "^3.0.5",
|
||||
"@types/jsdom": "^21.1.6",
|
||||
"@types/marked": "^5.0.2",
|
||||
"concurrently": "^8.2.2",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-next": "14.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import matter from 'gray-matter';
|
||||
import { remark } from 'remark';
|
||||
import html from 'remark-html';
|
||||
import gfm from 'remark-gfm';
|
||||
import { marked } from 'marked';
|
||||
import DOMPurify from 'dompurify';
|
||||
import { JSDOM } from 'jsdom';
|
||||
import chokidar from 'chokidar';
|
||||
import type { FSWatcher } from 'chokidar';
|
||||
import remarkRehype from 'remark-rehype';
|
||||
import rehypeRaw from 'rehype-raw';
|
||||
import rehypeStringify from 'rehype-stringify';
|
||||
|
||||
export interface Post {
|
||||
slug: string;
|
||||
@@ -36,12 +33,38 @@ export async function getPostBySlug(slug: string): Promise<Post> {
|
||||
const { data, content } = matter(fileContents);
|
||||
const createdAt = getFileCreationDate(fullPath);
|
||||
|
||||
const processedContent = await remark()
|
||||
.use(gfm)
|
||||
.use(remarkRehype, { allowDangerousHtml: true })
|
||||
.use(rehypeRaw)
|
||||
.use(rehypeStringify)
|
||||
.process(content);
|
||||
let processedContent = '';
|
||||
try {
|
||||
marked.setOptions({
|
||||
gfm: true,
|
||||
breaks: true
|
||||
});
|
||||
const rawHtml = marked.parse(content);
|
||||
const window = new JSDOM('').window;
|
||||
const purify = DOMPurify(window);
|
||||
processedContent = purify.sanitize(rawHtml as string, {
|
||||
ALLOWED_TAGS: [
|
||||
'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
|
||||
'p', 'a', 'ul', 'ol', 'li', 'blockquote',
|
||||
'pre', 'code', 'em', 'strong', 'del',
|
||||
'hr', 'br', 'img', 'table', 'thead', 'tbody',
|
||||
'tr', 'th', 'td', 'div', 'span', 'iframe'
|
||||
],
|
||||
ALLOWED_ATTR: [
|
||||
'class', 'id', 'style',
|
||||
'href', 'target', 'rel',
|
||||
'src', 'alt', 'title', 'width', 'height',
|
||||
'frameborder', 'allowfullscreen'
|
||||
],
|
||||
ALLOWED_URI_REGEXP: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(`Error processing markdown for ${realSlug}:`, err);
|
||||
processedContent = `<div class="error-message">
|
||||
<p>Error processing markdown content. Please check the console for details.</p>
|
||||
<pre>${err instanceof Error ? err.message : 'Unknown error'}</pre>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
return {
|
||||
slug: realSlug,
|
||||
@@ -49,7 +72,7 @@ export async function getPostBySlug(slug: string): Promise<Post> {
|
||||
date: data.date,
|
||||
tags: data.tags || [],
|
||||
summary: data.summary,
|
||||
content: processedContent.toString(),
|
||||
content: processedContent,
|
||||
createdAt,
|
||||
author: process.env.NEXT_PUBLIC_BLOG_OWNER || 'Anonymous',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user