fix: resolve legal/about pages in production, update deploy docs

- Fix markdown file path resolution for SSR production builds
- Try multiple paths (public/legal, client/legal) for dev and prod
- Update deploy/README.md with frontend deployment instructions
- Document PM2, Nginx configuration, and port mapping
This commit is contained in:
zl-q
2026-05-11 19:09:35 +08:00
parent dda8014428
commit 91c089a894
3 changed files with 154 additions and 10 deletions
+16 -5
View File
@@ -17,12 +17,23 @@ const titleMap: Record<Locale, string> = {
en: 'About Us',
};
const filePath = path.resolve('public/legal', locale, 'about_us.md');
// Try multiple paths for dev and production environments
const possiblePaths = [
path.resolve('public/legal', locale, 'about_us.md'),
path.resolve('client/legal', locale, 'about_us.md'),
path.resolve('../client/legal', locale, 'about_us.md'),
];
let raw = '';
try {
raw = fs.readFileSync(filePath, 'utf-8');
raw = raw.replace(/^#\s+.+\n*/m, '');
} catch {
for (const filePath of possiblePaths) {
try {
raw = fs.readFileSync(filePath, 'utf-8');
raw = raw.replace(/^#\s+.+\n*/m, '');
break;
} catch {
// Try next path
}
}
if (!raw) {
raw = `Content not available.`;
}
const content = await marked(raw);
+16 -5
View File
@@ -46,12 +46,23 @@ const subtitle = subtitleMap[docType]?.[locale] ?? '';
const warning = warningMap[locale];
const legalTitle = legalTitleMap[locale];
const filePath = path.resolve('public/legal', locale, `${docType}.md`);
// Try multiple paths for dev and production environments
const possiblePaths = [
path.resolve('public/legal', locale, `${docType}.md`),
path.resolve('client/legal', locale, `${docType}.md`),
path.resolve('../client/legal', locale, `${docType}.md`),
];
let raw = '';
try {
raw = fs.readFileSync(filePath, 'utf-8');
raw = raw.replace(/^#\s+.+\n*/m, '');
} catch {
for (const filePath of possiblePaths) {
try {
raw = fs.readFileSync(filePath, 'utf-8');
raw = raw.replace(/^#\s+.+\n*/m, '');
break;
} catch {
// Try next path
}
}
if (!raw) {
raw = `Content not available.`;
}
const content = await marked(raw);