File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { useLocation } from 'react-router-dom'
12import { Head } from 'vite-react-ssg'
23import { site } from '../site'
34
4- export default function Seo ( { title, description } : { title : string ; description : string } ) {
5+ type Props = { title : string ; description : string ; schema ?: object }
6+
7+ export default function Seo ( { title, description, schema } : Props ) {
8+ const { pathname } = useLocation ( )
9+ const canonical = site . origin + ( pathname === '/' ? '/' : pathname . replace ( / \. h t m l $ | \/ $ / , '' ) )
10+
511 return (
612 < Head >
713 < title > { title } </ title >
814 < meta name = "description" content = { description } />
15+ < link rel = "canonical" href = { canonical } />
16+ < meta property = "og:type" content = "website" />
17+ < meta property = "og:url" content = { canonical } />
918 < meta property = "og:title" content = { title } />
1019 < meta property = "og:description" content = { description } />
1120 < meta property = "og:image" content = { site . avatar } />
1221 < meta name = "twitter:card" content = "summary" />
22+ { schema && < script type = "application/ld+json" > { JSON . stringify ( schema ) } </ script > }
1323 </ Head >
1424 )
1525}
Original file line number Diff line number Diff line change @@ -15,7 +15,20 @@ export default function Article({ entry, series }: Props) {
1515
1616 return (
1717 < article className = "section-white py-5" >
18- < Seo title = { `${ meta . title } — ${ site . name } ` } description = { meta . description } />
18+ < Seo
19+ title = { `${ meta . title } — ${ site . name } ` }
20+ description = { meta . description }
21+ schema = { {
22+ '@context' : 'https://schema.org' ,
23+ '@type' : 'Article' ,
24+ headline : meta . title ,
25+ description : meta . description ,
26+ url : `${ site . origin } /${ entry . kind } /${ entry . slug } ` ,
27+ author : { '@type' : 'Person' , name : site . name , url : site . origin } ,
28+ publisher : { '@type' : 'Person' , name : site . name , url : site . origin } ,
29+ ...( meta . date && { datePublished : meta . date } ) ,
30+ } }
31+ />
1932 < div aria-hidden className = "read-progress" />
2033 < div className = "container pt-md-4" style = { { maxWidth : 768 } } >
2134 < a href = { isBlog ? '/blog' : '/#case-studies' } className = "d-inline-flex gap-1 small text-body-secondary mb-4" >
Original file line number Diff line number Diff line change @@ -9,7 +9,21 @@ import { site } from '../site'
99export default function Home ( ) {
1010 return (
1111 < >
12- < Seo title = { `${ site . name } — ${ site . role } ` } description = { site . description } />
12+ < Seo
13+ title = { `${ site . name } — ${ site . role } ` }
14+ description = { site . description }
15+ schema = { {
16+ '@context' : 'https://schema.org' ,
17+ '@type' : 'Person' ,
18+ name : site . name ,
19+ jobTitle : site . role ,
20+ description : site . description ,
21+ url : site . origin ,
22+ image : site . avatar ,
23+ email : `mailto:${ site . email } ` ,
24+ sameAs : [ site . linkedin , site . github ] ,
25+ } }
26+ />
1327 < Hero />
1428 < CaseStudies />
1529 < Testimonials />
Original file line number Diff line number Diff line change 11export const site = {
2+ origin : 'https://intellycode.dev' ,
23 name : 'Denis Zenios' ,
34 brand : 'IntellyCode' ,
45 role : 'Computational Engineer' ,
Original file line number Diff line number Diff line change @@ -7,6 +7,26 @@ import remarkMdxFrontmatter from 'remark-mdx-frontmatter'
77import remarkMath from 'remark-math'
88import rehypeKatex from 'rehype-katex'
99import { toString } from 'mdast-util-to-string'
10+ import { readdirSync , writeFileSync } from 'node:fs'
11+
12+ const ORIGIN = 'https://intellycode.dev'
13+
14+ function slugsIn ( kind : string ) {
15+ return readdirSync ( `src/content/${ kind } ` )
16+ . filter ( ( file ) => file . endsWith ( '.mdx' ) )
17+ . map ( ( file ) => `/${ kind } /${ file . replace ( '.mdx' , '' ) } ` )
18+ }
19+
20+ function writeSitemap ( dir : string ) {
21+ const paths = [ '/' , '/blog' , ...slugsIn ( 'case-studies' ) , ...slugsIn ( 'blog' ) ]
22+ const urls = paths . map ( ( path ) => ` <url><loc>${ ORIGIN } ${ path } </loc></url>` ) . join ( '\n' )
23+
24+ writeFileSync (
25+ `${ dir } /sitemap.xml` ,
26+ `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${ urls } \n</urlset>\n` ,
27+ )
28+ writeFileSync ( dir + '/robots.txt' , `User-agent: *\nAllow: /\n\nSitemap: ${ ORIGIN } /sitemap.xml\n` )
29+ }
1030
1131function remarkReadingMinutes ( ) {
1232 return ( tree : any ) => {
@@ -36,5 +56,6 @@ export default defineConfig({
3656 } ,
3757 ssgOptions : {
3858 dirStyle : 'flat' ,
59+ onFinished : writeSitemap ,
3960 } ,
4061} )
You can’t perform that action at this time.
0 commit comments