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:
35
bin/data/profile/index.ts
Normal file
35
bin/data/profile/index.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
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 };
|
||||
Reference in New Issue
Block a user