#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const { marked } = require('marked');
const { markedHighlight } = require('marked-highlight');
const hljs = require('highlight.js');
marked.use(markedHighlight({
langPrefix: 'hljs language-',
highlight(code, lang) {
const language = hljs.getLanguage(lang) ? lang : 'plaintext';
return hljs.highlight(code, { language }).value;
}
}));
const renderer = new marked.Renderer();
renderer.link = function(token) {
const href = token.href;
const title = token.title;
const text = token.text;
const titleAttr = title ? ` title="${title}"` : '';
if (text.includes('`;
}
return `${text}`;
}
return `${text}`;
};
marked.setOptions({
breaks: false,
gfm: true,
headerIds: true,
mangle: false,
pedantic: false,
sanitize: false,
silent: false,
smartLists: true,
smartypants: false,
xhtml: false,
renderer: renderer
});
const readmePath = path.join(__dirname, '../README.md');
const readmeContent = fs.readFileSync(readmePath, 'utf-8');
function parseReadme(content) {
const titleMatch = content.match(/^# (.+)$/m);
const title = titleMatch ? titleMatch[1] : 'EdgeOne Pages Hono Application';
const descMatch = content.match(/This is a modern Web application[^\n]+/);
const description = descMatch ? descMatch[0] : '';
const liveDemoMatch = content.match(/Live demo: (.+)$/m);
const liveDemo = liveDemoMatch ? liveDemoMatch[0] : '';
const hasDeployButton = content.includes('Deploy with EdgeOne Pages');
const htmlContent = marked(content);
return {
title,
description,
liveDemo,
hasDeployButton,
htmlContent
};
}
function generateHTML(data) {
return `
This is a complete example application demonstrating various features and best practices of the Hono framework on EdgeOne Functions.
The project structure is clear, code is well organized, and suitable as a starting template for other projects.