Skip to content

Commit ab637dd

Browse files
committed
feat(metadataCache): Add metadataCache as site properties for better component support.
1 parent afe06f5 commit ab637dd

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/exporter.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const openUrl = async (url: string) => {
5858
// Publish list of files
5959
export const publishFiles = async (
6060
client: RemoteClient,
61-
vault: any,
61+
app: any,
6262
pathList: string[],
6363
allFiles: TFile[],
6464
password: string = "",
@@ -67,6 +67,7 @@ export const publishFiles = async (
6767
view?: StatsView,
6868
cb?: (key: string, status: 'START' | 'DONE' | 'FAIL', meta?: any) => any,
6969
) => {
70+
const vault = app.vault;
7071
const htmlPath = AssetHandler.initHtmlPath();
7172

7273
if (allFiles.length > 100000 || allFiles.length < 0)
@@ -123,9 +124,23 @@ export const publishFiles = async (
123124
path: `${sitemapDownload.relativeDownloadPath.asString}/${sitemapDownload.filename}`,
124125
key: settings.localWatchDir + '/' + sitemapDownload.filename,
125126
})
126-
log.info('sitemap - ', sitemapDomStr, htmlPath);
127+
log.info('generating sitemap...');
127128
externalFiles.push(sitemapDownload);
128129
}
130+
// metadataCache
131+
const filesMetadata: any = {};
132+
allFiles.forEach(file => {
133+
filesMetadata[file.path] = app.metadataCache.getFileCache(file)
134+
});
135+
136+
const metaDownload = new Downloadable('meta.json', JSON.stringify(filesMetadata), htmlPath.joinString(settings.localWatchDir));
137+
Object.assign(metaDownload, {
138+
path: `${metaDownload.relativeDownloadPath.asString}/${metaDownload.filename}`,
139+
key: settings.localWatchDir + '/' + metaDownload.filename,
140+
})
141+
log.info('generating meta...');
142+
externalFiles.push(metaDownload);
143+
129144
externalFiles = externalFiles.filter((file, index) => externalFiles.findIndex((f) => f.relativeDownloadPath == file.relativeDownloadPath && f.filename === file.filename) == index);
130145
await Utils.downloadFiles(externalFiles, htmlPath, view);
131146
log.info('download files to: ', htmlPath, externalFiles);

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ export default class InvioPlugin extends Plugin {
518518
pubPathList.push(indexFile.path);
519519
}
520520
}
521-
await publishFiles(client, this.app.vault, pubPathList, allFiles, '', this.settings, triggerSource, view, (pathName: string, status: string, meta?: any) => {
521+
await publishFiles(client, this.app, pubPathList, allFiles, '', this.settings, triggerSource, view, (pathName: string, status: string, meta?: any) => {
522522
log.info('publishing ', pathName, status);
523523
if (status === 'START') {
524524
log.info('set file start publishing', pathName);
@@ -541,7 +541,7 @@ export default class InvioPlugin extends Plugin {
541541
}
542542
}
543543
}
544-
await publishFiles(client, this.app.vault, forceList, allFiles, '', this.settings, triggerSource);
544+
await publishFiles(client, this.app, forceList, allFiles, '', this.settings, triggerSource);
545545
}
546546
HTMLGenerator.endBatch();
547547
} else {

0 commit comments

Comments
 (0)