fix: resolve issues #10 and #11 for metadata and preview language

Co-authored-by: rfc1437 <774975+rfc1437@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-17 17:52:56 +00:00
parent 6802aa40fa
commit 7c81d76a4b
4 changed files with 52 additions and 24 deletions

View File

@@ -284,9 +284,9 @@ function buildCanonicalPostPath(post: PostData): string {
return `/${year}/${month}/${day}/${post.slug}`;
}
function getPageHtml(content: string, title: string): string {
function getPageHtml(content: string, title: string, language: string): string {
return `<!doctype html>
<html lang="en">
<html lang="${escapeHtml(language)}">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
@@ -452,7 +452,8 @@ export class PreviewServer {
return;
}
this.respond(res, 200, getPageHtml(result, resolvePageTitle(metadata, context.projectName, context.projectDescription)));
const language = metadata?.mainLanguage?.trim() || 'en';
this.respond(res, 200, getPageHtml(result, resolvePageTitle(metadata, context.projectName, context.projectDescription), language));
} catch (error) {
console.error('[PreviewServer] Request failed:', error);
this.respond(res, 500, 'Internal Server Error');