Files
morten-olsen.github.io/bin/data/profile/index.ts
Morten Olsen 9b1a067d56 init
2023-03-27 10:46:18 +02:00

36 lines
812 B
TypeScript

import { resolve } from "path";
import { createFile } from "../../resources/file";
import YAML from "yaml";
import { Bundler } from "../../bundler";
import { Profile } from "../../../types";
import { createImage } from "../../resources/image";
type ProfileOptions = {
bundler: Bundler;
};
const createProfile = ({ bundler }: ProfileOptions) => {
const file = createFile({
path: resolve("content/profile.yml"),
});
const profile = file.pipe(async (yaml) => {
const data = YAML.parse(yaml);
const imagePath = resolve("content", data.image);
const result: Profile = {
...data,
imageUrl: createImage({
image: imagePath,
format: "avif",
bundler,
}),
imagePath,
};
return result;
});
return profile;
};
export { createProfile };