mirror of
https://github.com/morten-olsen/morten-olsen.github.io.git
synced 2026-02-08 01:46:28 +01:00
feat: added latex generation
This commit is contained in:
30
src/data/assets/WebpackAssets.ts
Normal file
30
src/data/assets/WebpackAssets.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import path from 'path';
|
||||
import { AssetResolver } from './';
|
||||
|
||||
const assetModules = (require as any).context(
|
||||
'../../../content',
|
||||
true,
|
||||
/\.(png|jpe?g|svg|gif|tex\.yml)$/,
|
||||
)
|
||||
const assets = assetModules.keys().reduce((output, key: string) => ({
|
||||
...output,
|
||||
[path.resolve(
|
||||
'/',
|
||||
key,
|
||||
)]: assetModules(key).default || assetModules(key),
|
||||
}), {} as any);
|
||||
|
||||
class WebpackAssetResolver extends AssetResolver {
|
||||
#assets = assets;
|
||||
|
||||
public getPath = (...location: string[]) => {
|
||||
const target = path.resolve(
|
||||
'/',
|
||||
...location,
|
||||
);
|
||||
const assetModule = this.#assets[target];
|
||||
return assetModule;
|
||||
}
|
||||
}
|
||||
|
||||
export { WebpackAssetResolver };
|
||||
Reference in New Issue
Block a user