Initial Montech monorepo: Nuxt landing, Vue admin, Nest API.
Scaffold SSR site with CMS/blog/gallery/SEO admin and deploy configs for montech.ir. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
export default defineEventHandler((event) => {
|
||||
const config = useRuntimeConfig();
|
||||
const site = config.public.siteUrl || "https://montech.ir";
|
||||
setHeader(event, "Content-Type", "text/plain");
|
||||
return `User-agent: *\nAllow: /\nDisallow: /adm\nSitemap: ${site}/sitemap.xml\n`;
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const config = useRuntimeConfig();
|
||||
const site = config.public.siteUrl || "https://montech.ir";
|
||||
const apiBase = config.apiBase || "http://127.0.0.1:3050";
|
||||
|
||||
let posts: Array<{ slug: string; updatedAt?: string; publishedAt?: string }> = [];
|
||||
try {
|
||||
posts = await $fetch(`${apiBase}/api/public/blog`);
|
||||
} catch {
|
||||
posts = [];
|
||||
}
|
||||
|
||||
const staticUrls = ["", "/blog", "/gallery"];
|
||||
const urls = [
|
||||
...staticUrls.map((path) => ({ loc: `${site}${path || "/"}`, changefreq: "weekly", priority: path === "" ? "1.0" : "0.8" })),
|
||||
...posts.map((p) => ({
|
||||
loc: `${site}/blog/${p.slug}`,
|
||||
changefreq: "monthly",
|
||||
priority: "0.6",
|
||||
lastmod: p.updatedAt || p.publishedAt,
|
||||
})),
|
||||
];
|
||||
|
||||
const body = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
${urls
|
||||
.map(
|
||||
(u) => ` <url>
|
||||
<loc>${u.loc}</loc>
|
||||
${"lastmod" in u && u.lastmod ? `<lastmod>${new Date(u.lastmod as string).toISOString()}</lastmod>` : ""}
|
||||
<changefreq>${u.changefreq}</changefreq>
|
||||
<priority>${u.priority}</priority>
|
||||
</url>`,
|
||||
)
|
||||
.join("\n")}
|
||||
</urlset>`;
|
||||
|
||||
setHeader(event, "Content-Type", "application/xml");
|
||||
return body;
|
||||
});
|
||||
Reference in New Issue
Block a user