文件
mynode/packages/renderer/assetsToHeaders.ts
chen 301194963b
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
feat: Initial clean release of CHM
2026-11-04 11:29:39 +08:00

35 行
994 B
TypeScript

import { RenderResultPluginAsset } from './types';
interface Options {
asHtml: boolean;
}
// Utility function to convert the plugin assets to a list of LINK or SCRIPT tags
// that can be included in the HEAD tag.
const assetsToHeaders = (pluginAssets: RenderResultPluginAsset[], options: Options|null = null) => {
options = { asHtml: false, ...options };
const headers: Record<string, string> = {};
for (let i = 0; i < pluginAssets.length; i++) {
const asset = pluginAssets[i];
if (asset.mime === 'text/css') {
headers[asset.name] = `<link rel="stylesheet" href="pluginAssets/${asset.name}">`;
} else if (asset.mime === 'application/javascript') {
// NOT TESTED!!
headers[asset.name] = `<script type="application/javascript" src="pluginAssets/${asset.name}"></script>`;
}
}
if (options.asHtml) {
const output = [];
for (const name in headers) {
output.push(headers[name]);
}
return output.join('');
}
return headers;
};
export default assetsToHeaders;