1212import type { APIRoute , GetStaticPaths } from 'astro' ;
1313import { getEntry } from 'astro:content' ;
1414import { getMarkdownRegistry } from '@utils/markdownRegistry' ;
15- import { renderEntryMarkdown } from '@utils/pageMarkdown' ;
15+ import { markdownSeoHeaders , renderEntryMarkdown } from '@utils/pageMarkdown' ;
1616
1717export const getStaticPaths : GetStaticPaths = async ( ) => {
1818 const registry = await getMarkdownRegistry ( ) ;
@@ -37,17 +37,19 @@ export const GET: APIRoute = async ({ props }) => {
3737 ) ;
3838 if ( ! entry ) return new Response ( 'Not found' , { status : 404 } ) ;
3939
40+ const canonicalUrl = `https://www.datum.net${ urlPath } /` ;
4041 const body = renderEntryMarkdown ( entry , {
4142 // Demote body headings so a body-level H1 doesn't compete with the
4243 // frontmatter title. Safe for all pages — pages without a body H1
4344 // are unaffected.
4445 demoteHeadings : true ,
45- sourceUrl : `https://www.datum.net ${ urlPath } /` ,
46+ sourceUrl : canonicalUrl ,
4647 } ) ;
4748 return new Response ( body , {
4849 headers : {
4950 'Content-Type' : 'text/markdown; charset=utf-8' ,
5051 'Cache-Control' : 'public, max-age=300, s-maxage=300' ,
52+ ...markdownSeoHeaders ( canonicalUrl ) ,
5153 } ,
5254 } ) ;
5355 } catch ( error ) {
0 commit comments