🔍 Sitemap support alias
This commit is contained in:
parent
81a021744c
commit
2169e9c564
@ -5,7 +5,7 @@ export default defineSitemapEventHandler(async () => {
|
|||||||
const result = await res.json()
|
const result = await res.json()
|
||||||
|
|
||||||
return result.data.map((item: any) => asSitemapUrl({
|
return result.data.map((item: any) => asSitemapUrl({
|
||||||
loc: `/posts/${item.id}`,
|
loc: item.alias ? `/posts/${item.area_alias}:${item.alias}` : `/posts/${item.id}`,
|
||||||
lastmod: item.edited_at ?? item.published_at,
|
lastmod: item.edited_at ?? item.published_at,
|
||||||
priority: 0.7,
|
priority: 0.7,
|
||||||
_sitemap: "posts",
|
_sitemap: "posts",
|
||||||
|
@ -50,9 +50,11 @@ export default defineEventHandler(async (event) => {
|
|||||||
.use(rehypeStringify)
|
.use(rehypeStringify)
|
||||||
.process(post.body.content)
|
.process(post.body.content)
|
||||||
|
|
||||||
|
const slug = post.alias ? `/posts/${post.area_alias}:${post.alias}` : `/posts/${post.id}`
|
||||||
|
|
||||||
feed.addItem({
|
feed.addItem({
|
||||||
date: new Date(post.published_at),
|
date: new Date(post.published_at),
|
||||||
link: `https://solsynth.dev/posts/${post.id}`,
|
link: `https://solsynth.dev/${slug}`,
|
||||||
title: post.body.title ?? `Post #${post.id}`,
|
title: post.body.title ?? `Post #${post.id}`,
|
||||||
description: post.body.description,
|
description: post.body.description,
|
||||||
content: String(content),
|
content: String(content),
|
||||||
|
Loading…
Reference in New Issue
Block a user