config ?
This commit is contained in:
@@ -6,12 +6,7 @@ const nextConfig = {
|
|||||||
// Ensure we can access the app from outside the container
|
// Ensure we can access the app from outside the container
|
||||||
experimental: {
|
experimental: {
|
||||||
outputFileTracingRoot: undefined,
|
outputFileTracingRoot: undefined,
|
||||||
},
|
}
|
||||||
// Configure the hostname and port
|
|
||||||
server: {
|
|
||||||
hostname: '0.0.0.0',
|
|
||||||
port: 8080,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = nextConfig
|
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",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"electron-dev": "electron .",
|
"electron": "electron .",
|
||||||
"electron-build": "next build && electron-builder"
|
"electron-dev": "concurrently \"npm run dev\" \"npm run electron\""
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tailwindcss/typography": "^0.5.16",
|
"@types/node": "^20.11.24",
|
||||||
"@types/dompurify": "^3.0.5",
|
"@types/react": "^18.2.61",
|
||||||
"@types/jsdom": "^21.1.7",
|
"@types/react-dom": "^18.2.19",
|
||||||
"@types/marked": "^5.0.2",
|
|
||||||
"autoprefixer": "^10.4.17",
|
"autoprefixer": "^10.4.17",
|
||||||
"bcrypt": "^6.0.0",
|
"chokidar": "^3.6.0",
|
||||||
"chokidar": "^4.0.3",
|
"dompurify": "^3.0.9",
|
||||||
"date-fns": "^3.3.1",
|
"electron": "^29.1.0",
|
||||||
"dompurify": "^3.2.6",
|
|
||||||
"gray-matter": "^4.0.3",
|
"gray-matter": "^4.0.3",
|
||||||
"jsdom": "^26.1.0",
|
"jsdom": "^24.0.0",
|
||||||
"marked": "^15.0.12",
|
"marked": "^12.0.0",
|
||||||
"next": "14.1.0",
|
"next": "14.1.0",
|
||||||
"postcss": "^8.4.35",
|
"postcss": "^8.4.35",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"rehype-raw": "^6.1.1",
|
"tailwindcss": "^3.4.1",
|
||||||
"rehype-sanitize": "^6.0.0",
|
"typescript": "^5.3.3",
|
||||||
"rehype-stringify": "^9.0.3",
|
"date-fns": "^3.6.0",
|
||||||
"remark": "^15.0.0",
|
"@tailwindcss/typography": "^0.5.16"
|
||||||
"remark-gfm": "^3.0.1",
|
|
||||||
"remark-html": "^16.0.1",
|
|
||||||
"remark-parse": "^11.0.0",
|
|
||||||
"remark-rehype": "^11.0.0",
|
|
||||||
"tailwindcss": "^3.4.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bcrypt": "^5.0.2",
|
"@types/dompurify": "^3.0.5",
|
||||||
"@types/chokidar": "^1.7.5",
|
"@types/jsdom": "^21.1.6",
|
||||||
"@types/node": "^20.11.19",
|
"@types/marked": "^5.0.2",
|
||||||
"@types/react": "^18.2.57",
|
"concurrently": "^8.2.2",
|
||||||
"@types/react-dom": "^18.2.19",
|
"eslint": "^8.57.0",
|
||||||
"electron": "^28.2.3",
|
"eslint-config-next": "14.1.0"
|
||||||
"electron-builder": "^24.9.1",
|
|
||||||
"eslint": "^8.56.0",
|
|
||||||
"eslint-config-next": "14.1.0",
|
|
||||||
"typescript": "^5.3.3"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import matter from 'gray-matter';
|
import matter from 'gray-matter';
|
||||||
import { remark } from 'remark';
|
import { marked } from 'marked';
|
||||||
import html from 'remark-html';
|
import DOMPurify from 'dompurify';
|
||||||
import gfm from 'remark-gfm';
|
import { JSDOM } from 'jsdom';
|
||||||
import chokidar from 'chokidar';
|
import chokidar from 'chokidar';
|
||||||
import type { FSWatcher } 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 {
|
export interface Post {
|
||||||
slug: string;
|
slug: string;
|
||||||
@@ -36,12 +33,38 @@ export async function getPostBySlug(slug: string): Promise<Post> {
|
|||||||
const { data, content } = matter(fileContents);
|
const { data, content } = matter(fileContents);
|
||||||
const createdAt = getFileCreationDate(fullPath);
|
const createdAt = getFileCreationDate(fullPath);
|
||||||
|
|
||||||
const processedContent = await remark()
|
let processedContent = '';
|
||||||
.use(gfm)
|
try {
|
||||||
.use(remarkRehype, { allowDangerousHtml: true })
|
marked.setOptions({
|
||||||
.use(rehypeRaw)
|
gfm: true,
|
||||||
.use(rehypeStringify)
|
breaks: true
|
||||||
.process(content);
|
});
|
||||||
|
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 {
|
return {
|
||||||
slug: realSlug,
|
slug: realSlug,
|
||||||
@@ -49,7 +72,7 @@ export async function getPostBySlug(slug: string): Promise<Post> {
|
|||||||
date: data.date,
|
date: data.date,
|
||||||
tags: data.tags || [],
|
tags: data.tags || [],
|
||||||
summary: data.summary,
|
summary: data.summary,
|
||||||
content: processedContent.toString(),
|
content: processedContent,
|
||||||
createdAt,
|
createdAt,
|
||||||
author: process.env.NEXT_PUBLIC_BLOG_OWNER || 'Anonymous',
|
author: process.env.NEXT_PUBLIC_BLOG_OWNER || 'Anonymous',
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user