@@ -342,12 +342,28 @@ aws.initConfig(awsProps)
342342 ogTitle : result . specialMetadata ? result . specialMetadata . title . S : "Compiler Explorer"
343343 } ;
344344 if ( ! metadata . ogDescription ) {
345- const sources = utils . glGetEditorSources ( config . content ) ;
346- if ( sources . length === 1 ) {
347- const lang = languages [ sources [ 0 ] . language ] ;
348- metadata . ogDescription = sources [ 0 ] . source ;
345+ const sources = utils . glGetMainContents ( config . content ) ;
346+ if ( sources . editors . length === 1 ) {
347+ const editor = sources . editors [ 0 ] ;
348+ const lang = languages [ editor . language ] ;
349349 if ( lang ) {
350+ let code = editor . source ;
351+ if ( lang . previewFilter ) {
352+ code = _ . filter ( code . split ( '\n' ) , line => {
353+ return ! line . match ( lang . previewFilter ) ;
354+ } ) . join ( '\n' ) ;
355+ }
356+ metadata . ogDescription = code ;
350357 metadata . ogTitle += ` - ${ lang . name } ` ;
358+ if ( sources . compilers . length === 1 ) {
359+ const compilerId = sources . compilers [ 0 ] . compiler ;
360+ const compiler = apiHandler . compilers . find ( c => c . id === compilerId ) ;
361+ if ( compiler ) {
362+ metadata . ogTitle += ` (${ compiler . name } )` ;
363+ }
364+ }
365+ } else {
366+ metadata . ogDescription = editor . source ;
351367 }
352368 }
353369 } else if ( metadata . ogAuthor && metadata . ogAuthor !== '.' ) {
@@ -361,7 +377,8 @@ aws.initConfig(awsProps)
361377 metadata : metadata
362378 } ) ) ;
363379 } )
364- . catch ( ( ) => {
380+ . catch ( err => {
381+ logger . warn ( `Exception thrown when expanding ${ id } : ` , err ) ;
365382 next ( {
366383 statusCode : 404 ,
367384 message : `ID "${ id } " could not be found`
0 commit comments