File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed
Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -3,3 +3,4 @@ NUXT_SITE_URL= # https://github.com/harlan-zw/nuxt-site-config/issues/32
33NUXT_PUBLIC_BE_URL =
44NUXT_PUBLIC_INSTANCE_NAME =
55NUXT_PUBLIC_FOOTER_TEXT =
6+ NUXT_PUBLIC_TIEBA_IMAGE_PROXY =
Original file line number Diff line number Diff line change @@ -67,7 +67,8 @@ export default defineNuxtConfig({
6767 public : keysWithSameValue ( [
6868 'beUrl' ,
6969 'instanceName' ,
70- 'footerText'
70+ 'footerText' ,
71+ 'tiebaImageProxy'
7172 ] , '' )
7273 }
7374} ) ;
Original file line number Diff line number Diff line change 11export const extractContentTexts = ( content ?: PostContent | null ) => content
22 ?. reduce ( ( acc , i ) => acc + ( 'text' in i ? i . text ?? '' : '' ) , '' ) ?? '' ;
33export const toHTTPS = ( url ?: string ) => url ?. replace ( 'http://' , 'https://' ) ;
4- export const imageUrl = ( originSrc ?: string ) =>
5- ( originSrc !== undefined && / ^ (?: [ 0 - 9 a - f ] { 40 } | [ 0 - 9 a - f ] { 24 } ) $ / u. test ( originSrc )
6- ? `https://imgsrc.baidu.com/forum/pic/item/${ originSrc } .jpg`
7- : originSrc ) ;
4+ const config = useRuntimeConfig ( ) . public ;
5+ export const imageUrl = ( originSrc ?: string ) => {
6+ if ( originSrc === undefined || ! / ^ (?: [ 0 - 9 a - f ] { 40 } | [ 0 - 9 a - f ] { 24 } ) $ / u. test ( originSrc ) )
7+ return originSrc ;
8+ if ( config . tiebaImageProxy !== '' )
9+ return `${ config . tiebaImageProxy } /${ originSrc } ` ;
10+
11+ return `https://imgsrc.baidu.com/forum/pic/item/${ originSrc } .jpg` ;
12+ } ;
813export const tryExtractTiebaOutboundUrl = ( rawURL ?: string ) => {
914 const url = new URL ( rawURL ?? '' ) ;
1015 if ( url . hostname === 'tieba.baidu.com' && url . pathname === '/mo/q/checkurl' )
You can’t perform that action at this time.
0 commit comments