@@ -29,6 +29,7 @@ import {query as postRootQuery} from './PostRoot';
29
29
import { query as postsRootQuery } from './PostsRoot' ;
30
30
import CommentsIcon from './CommentsIcon' ;
31
31
import parseMarkdown from './lib/parseMarkdown' ;
32
+ import Head from 'next/head' ;
32
33
33
34
import type { Post_post } from './__generated__/Post_post.graphql' ;
34
35
@@ -513,20 +514,20 @@ function postBackmatter(post) {
513
514
return backmatter ;
514
515
}
515
516
516
- export function computePostDate ( post : {
517
- + body : string ,
518
- + createdAt : string ,
519
- } ) : Date {
520
- const backmatter = postBackmatter ( post ) ;
517
+ export function computePostDate ( { backmatter, createdAt} ) : Date {
521
518
if ( backmatter . publishedDate ) {
522
519
return new Date ( backmatter . publishedDate ) ;
523
520
}
524
- return new Date ( post . createdAt ) ;
521
+ return new Date ( createdAt ) ;
525
522
}
526
523
527
524
export const Post = ( { relay, post, context} : Props ) => {
528
525
const environment = useRelayEnvironment ( ) ;
529
- const postDate = React . useMemo ( ( ) => computePostDate ( post ) , [ post ] ) ;
526
+ const backmatter = React . useMemo ( ( ) => postBackmatter ( post ) , [ post ] ) ;
527
+ const postDate = React . useMemo (
528
+ ( ) => computePostDate ( { backmatter, createdAt : post . createdAt } ) ,
529
+ [ post ] ,
530
+ ) ;
530
531
const number = post . number ;
531
532
532
533
const { loginStatus} = React . useContext ( UserContext ) ;
@@ -573,6 +574,11 @@ export const Post = ({relay, post, context}: Props) => {
573
574
const authors = post . assignees . nodes || [ ] ;
574
575
return (
575
576
< PostBox >
577
+ < Head >
578
+ { backmatter . canonical ? (
579
+ < link rel = "canonical" href = { backmatter . canonical } />
580
+ ) : null }
581
+ </ Head >
576
582
< Box pad = "medium" >
577
583
< Heading level = { 1 } margin = "none" >
578
584
{ context === 'details' ? (
0 commit comments