@@ -14,9 +14,33 @@ export default class ThumbnailPlugin extends Plugin {
1414 async onload ( ) {
1515 await this . loadSettings ( ) ;
1616
17- this . addRibbonIcon ( "document" , "Create thumbnail" , async ( ) => {
17+ this . addRibbonIcon ( "documents" , "Create thumbnails" , async ( ) => {
18+ let bases = await getBases ( this . app ) ;
19+ console . debug ( bases ) ;
20+ for ( const base of bases ) {
21+ console . debug ( base ) ;
22+ let files = getFiles ( this . app , base ) ;
23+ for ( const file of files ) {
24+ console . debug ( file ) ;
25+ if ( file instanceof TFile ) {
26+ let path = await generate ( this . app , this , file , 16 , 9 ) ;
27+ if ( typeof path === "string" ) {
28+ await this . app . fileManager . processFrontMatter ( file , ( frontmatter : Record < string , unknown > ) => {
29+ frontmatter [ "thumbnail" ] = `[[${ path } ]]` ;
30+ } ) ;
31+ }
32+ } else {
33+ console . error ( "Not a file open, not generating thumbnail." ) ;
34+ return ;
35+ }
36+ } ;
37+ } ;
38+ } ) ;
39+
40+ this . addRibbonIcon ( "document" , "Create thumbnail for this document" , async ( ) => {
1841 const file = this . app . workspace . getActiveFile ( ) ;
19- if ( file instanceof TFile ) {
42+
43+ if ( file instanceof TFile && file . extension != "base" ) {
2044 let path = await generate ( this . app , this , file , 16 , 9 ) ;
2145 if ( typeof path === "string" ) {
2246 await this . app . fileManager . processFrontMatter ( file , ( frontmatter : Record < string , unknown > ) => {
@@ -27,14 +51,9 @@ export default class ThumbnailPlugin extends Plugin {
2751 console . error ( "Not a file open, not generating thumbnail." ) ;
2852 return ;
2953 }
30- } ) ;
54+ } )
3155
3256 this . addSettingTab ( new SettingTab ( this . app , this ) ) ;
33-
34- let bases = await getBases ( this . app ) ;
35- bases . forEach ( ( base ) => {
36- console . debug ( getFiles ( this . app , base ) ) ;
37- } ) ;
3857 }
3958
4059 onunload ( ) {
0 commit comments