@@ -25,9 +25,10 @@ type Props = {
2525 error ?: string ;
2626 data ?: { [ key : string ] : any } ;
2727 fallback ?: boolean ;
28+ filePath ?: string ;
2829} ;
2930
30- const Page = ( { source, error, data, fallback } : Props ) => {
31+ const Page = ( { source, error, data, fallback, filePath } : Props ) => {
3132 if ( error ) {
3233 return (
3334 < section >
@@ -37,7 +38,11 @@ const Page = ({ source, error, data, fallback }: Props) => {
3738 }
3839
3940 const content =
40- source && hydrate ( source , { components : components as Components } ) ;
41+ source &&
42+ hydrate ( source , {
43+ components : components as Components ,
44+ fileName : filePath ,
45+ } ) ;
4146
4247 const codeColor = useColorModeValue (
4348 "var(--chakra-colors-gray-200)" ,
@@ -87,7 +92,6 @@ import {
8792import { renderToString } from "src/mdx-helpers/ssr" ;
8893import { RawContent } from "src/types/content" ;
8994import { Components } from "@mdx-js/react" ;
90- import { concat , flatten , flow , map } from "lodash/fp" ;
9195import rehypeStarryNight from "@microflash/rehype-starry-night" ;
9296
9397export async function getStaticProps (
@@ -107,6 +111,7 @@ export async function getStaticProps(
107111
108112 const mdxSource = await renderToString ( content , {
109113 components : components as Components ,
114+ fileName : route . join ( "/" ) ,
110115 mdxOptions : {
111116 components : components as Components ,
112117 rehypePlugins : [
@@ -115,7 +120,14 @@ export async function getStaticProps(
115120 } ,
116121 } ) ;
117122
118- return { props : { source : mdxSource , data, fallback : result . fallback } } ;
123+ return {
124+ props : {
125+ source : mdxSource ,
126+ data,
127+ fallback : result . fallback ,
128+ filePath : route . join ( "/" ) ,
129+ } ,
130+ } ;
119131}
120132
121133export function getStaticPaths ( ) : GetStaticPathsResult {
0 commit comments