import type { TFile , MetadataCache , DataAdapter } from 'obsidian' ; import { getAllTags } from 'obsidian' ; export function parseTag ( tag , tagList ) { tag = tag . trim ( ) ; if ( tag . length === 0 ) { return ; } tagList . push ( tag ) ; while ( tag . contains ( "/" ) ) { tag = tag . substring ( 0 , tag . lastIndexOf ( "/" ) ) ; tagList . push ( tag ) ; } } export function FilterMDFiles ( file , tagList , metadataCache ) { if ( ! tagList || tagList . length === 0 ) { return true ; } let tags = getAllTags ( metadataCache . getFileCache ( file ) ) . map ( e => e . slice ( 1 , e . length ) ) ; if ( tags && tags . length > 0 ) { let filetags = [ ] ; tags . forEach ( tag => parseTag ( tag , filetags ) ) ; return tagList . every ( val => { return filetags . indexOf ( val as string ) >= 0 ; } ) ; } return false ; } date export function createDate ( date ) { let dateComp = date . split ( ',' ) ; return new Date ( + ( dateComp [ 0 ] ?? 0 ) , + ( dateComp [ 1 ] ?? 0 ) , + ( dateComp [ 2 ] ?? 0 ) , + ( dateComp [ 3 ] ?? 0 ) ) ; } param path export function getImgUrl ( vaultAdaptor , path ) { if ( ! path ) { return null ; } let regex = new RegExp ( '^https:\/\/' ) ; if ( path . match ( regex ) ) { return path ; } return vaultAdaptor . getResourcePath ( path ) ; }