@@ -4,8 +4,12 @@ const {createRemoteFileNode} = require("gatsby-source-filesystem")
44
55const { getImageUrlParameters} = require ( "./get-image-url-parameters" )
66
7- const GOOGLE_IMAGE_REGEX =
8- / ( h t t p s : \/ \/ [ a - z 0 - 9 ] * .g o o g l e u s e r c o n t e n t \. c o m \/ [ a - z A - Z 0 - 9 _ - ] * ) " ( [ ^ ) ] * ) " /
7+ const IMAGE_URL_REGEX =
8+ / h t t p s : \/ \/ [ a - z 0 - 9 ] * .g o o g l e u s e r c o n t e n t \. c o m \/ [ a - z A - Z 0 - 9 _ - ] * /
9+ const MD_URL_TITLE_REGEX = new RegExp (
10+ `(${ IMAGE_URL_REGEX . source } ) "([^)]*)"` ,
11+ "g"
12+ )
913
1014exports . onCreateNodeGoogleDocs = async ( {
1115 node,
@@ -21,7 +25,7 @@ exports.onCreateNodeGoogleDocs = async ({
2125
2226 const imageUrlParams = getImageUrlParameters ( pluginOptions )
2327
24- if ( node . cover && GOOGLE_IMAGE_REGEX . test ( node . cover . image ) ) {
28+ if ( node . cover && IMAGE_URL_REGEX . test ( node . cover . image ) ) {
2529 let fileNode
2630 try {
2731 const url = node . cover . image + imageUrlParams
@@ -49,16 +53,13 @@ exports.onCreateNodeGoogleDocs = async ({
4953 }
5054 }
5155
52- const googleImagesRegex = new RegExp ( GOOGLE_IMAGE_REGEX . source , "g" )
53- const googleImagesIterator = node . markdown . matchAll ( googleImagesRegex )
56+ const googleImagesIterator = node . markdown . matchAll ( MD_URL_TITLE_REGEX )
5457 const googleImages = [ ...googleImagesIterator ]
5558
5659 if ( Array . isArray ( googleImages ) ) {
5760 const filesNodes = await Promise . all (
5861 googleImages . map ( async ( image ) => {
59- // console.log(image)
6062 const [ , url , title ] = image
61- console . log ( title )
6263 let fileNode
6364 try {
6465 fileNode = await createRemoteFileNode ( {
0 commit comments