mirror of
https://github.com/morten-olsen/morten-olsen.github.io.git
synced 2026-02-08 01:46:28 +01:00
init
This commit is contained in:
45
bin/data/positions/index.ts
Normal file
45
bin/data/positions/index.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { createGlob } from "../../resources/glob";
|
||||
import { createFile } from "../../resources/file";
|
||||
import grayMatter from "gray-matter";
|
||||
import { Bundler } from "../../bundler";
|
||||
import { markdownBundleImages } from "../../utils/markdown";
|
||||
import { dirname } from "path";
|
||||
import { Position } from "../../../types";
|
||||
import { Observable } from "../../observable";
|
||||
|
||||
type PositionOptions = {
|
||||
bundler: Bundler;
|
||||
};
|
||||
|
||||
const createPositions = ({ bundler }: PositionOptions) => {
|
||||
const files = createGlob<Observable<Position>>({
|
||||
pattern: "content/resume/positions/**/*.md",
|
||||
create: (path) => {
|
||||
const file = createFile({ path });
|
||||
const position = file.pipe(async (raw) => {
|
||||
const { data, content } = grayMatter(raw);
|
||||
const { title } = data;
|
||||
const cwd = dirname(path);
|
||||
const markdown = await markdownBundleImages({
|
||||
cwd,
|
||||
content,
|
||||
bundler,
|
||||
});
|
||||
const result = {
|
||||
company: data.company,
|
||||
title,
|
||||
from: data.from,
|
||||
to: data.to,
|
||||
raw: content,
|
||||
content: markdown,
|
||||
} as any;
|
||||
return result;
|
||||
});
|
||||
return position;
|
||||
},
|
||||
});
|
||||
|
||||
return files;
|
||||
};
|
||||
|
||||
export { createPositions };
|
||||
Reference in New Issue
Block a user