mirror of
https://github.com/morten-olsen/morten-olsen.github.io.git
synced 2026-02-08 01:46:28 +01:00
feat: init
This commit is contained in:
5
packages/markdown-loader/.gitignore
vendored
Normal file
5
packages/markdown-loader/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
/node_modules/
|
||||
/*.logs
|
||||
/.yarn/
|
||||
/dist/
|
||||
11
packages/markdown-loader/package.json
Normal file
11
packages/markdown-loader/package.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "@morten-olsen/markdown-loader",
|
||||
"main": "./dist/index.js",
|
||||
"devDependencies": {
|
||||
"remark": "^13"
|
||||
},
|
||||
"dependencies": {
|
||||
"front-matter": "^4.0.2",
|
||||
"fs-extra": "^11.1.0"
|
||||
}
|
||||
}
|
||||
3
packages/markdown-loader/src/index.ts
Normal file
3
packages/markdown-loader/src/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { webpackLoader } from './loader';
|
||||
|
||||
export default webpackLoader;
|
||||
27
packages/markdown-loader/src/loader.ts
Normal file
27
packages/markdown-loader/src/loader.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import * as webpack from 'webpack';
|
||||
import fm from 'front-matter';
|
||||
|
||||
function webpackLoader(
|
||||
this: webpack.LoaderContext<{}>,
|
||||
contents: string = ''
|
||||
) {
|
||||
const callback = this.async();
|
||||
|
||||
const run = async () => {
|
||||
const { attributes, body } = fm(contents);
|
||||
return {
|
||||
attributes,
|
||||
body,
|
||||
};
|
||||
};
|
||||
|
||||
run()
|
||||
.then((content) => {
|
||||
callback(null, `module.exports=${JSON.stringify(content)}`);
|
||||
})
|
||||
.catch((error) => {
|
||||
callback(error);
|
||||
});
|
||||
}
|
||||
|
||||
export { webpackLoader };
|
||||
9
packages/markdown-loader/tsconfig.json
Normal file
9
packages/markdown-loader/tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist"
|
||||
},
|
||||
"include": [
|
||||
"./src"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user