File tree 3 files changed +13
-6
lines changed
3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change
1
+ Animation where only input is time. Once per year something interesting happens
Original file line number Diff line number Diff line change @@ -249,12 +249,13 @@ async function getPostData(
249
249
const { data, content } = await parseMdxFile ( mdxFilePath ) ;
250
250
const plain = remark ( ) . use ( stripMarkdown ) . processSync ( content ) . toString ( ) ;
251
251
252
+ const postPath = `/posts/${ data . slug } /` ;
252
253
const renderedMdxSource = await renderMdxToString ( content , {
253
254
components : {
254
255
...COMPONENTS ,
255
256
} ,
256
257
mdxOptions : {
257
- remarkPlugins : [ resolveLinks ] ,
258
+ remarkPlugins : [ [ resolveLinks , { currentPath : postPath } ] ] ,
258
259
} ,
259
260
} ) ;
260
261
const charCount = plain . replace ( / \s + / , "" ) . length ;
@@ -267,7 +268,7 @@ async function getPostData(
267
268
slug : data . slug ,
268
269
tags : data . tags ,
269
270
description : data . description ,
270
- path : `/posts/ ${ data . slug } ` ,
271
+ path : postPath ,
271
272
charCount,
272
273
html : renderedMdxSource . renderedOutput ,
273
274
} ;
Original file line number Diff line number Diff line change 1
1
import visit from "unist-util-visit" ;
2
2
3
- export function resolveLinks ( ) {
3
+ type Options = {
4
+ currentPath ?: string ;
5
+ } ;
6
+
7
+ export function resolveLinks ( opts : Options = { currentPath : "/" } ) {
4
8
return ( tree : any ) => {
5
9
// Visit all nodes that have .url attribute
6
10
// https://github.com/syntax-tree/mdast
@@ -14,9 +18,10 @@ export function resolveLinks() {
14
18
return ;
15
19
}
16
20
17
- if ( linkUrl . startsWith ( "/" ) ) {
18
- node . url = `https://kimmo.blog${ node . url } ` ;
19
- }
21
+ node . url = new URL (
22
+ linkUrl ,
23
+ `https://kimmo.blog${ opts . currentPath } `
24
+ ) . toString ( ) ;
20
25
} ) ;
21
26
} ;
22
27
}
You can’t perform that action at this time.
0 commit comments