This commit is contained in:
Morten Olsen
2023-03-26 22:15:07 +02:00
commit 9b1a067d56
80 changed files with 7889 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
import { createGlob } from "../../resources/glob";
import { createFile } from "../../resources/file";
import grayMatter from "gray-matter";
import { Article } from "../../../types/article";
import { Bundler } from "../../bundler";
import { markdownBundleImages } from "../../utils/markdown";
import { dirname, resolve } from "path";
import { createImage } from "../../resources/image";
type ArticleOptions = {
bundler: Bundler;
};
const createArticles = ({ bundler }: ArticleOptions) => {
const files = createGlob({
pattern: "content/articles/**/*.md",
create: (path) => {
const file = createFile({ path });
const article = file.pipe(async (raw) => {
const { data, content } = grayMatter(raw);
const { title, slug, cover, color } = data;
const cwd = dirname(path);
const markdown = await markdownBundleImages({
cwd,
content,
bundler,
});
const coverUrl = createImage({
image: resolve(cwd, cover),
format: "avif",
bundler,
});
const thumbUrl = createImage({
image: resolve(cwd, cover),
format: "avif",
width: 400,
bundler,
});
const result: Article = {
title,
raw: content,
cover,
root: cwd,
content: markdown,
coverUrl,
thumbUrl,
color,
slug,
} as any;
return result;
});
return article;
},
});
return files;
};
export { createArticles };

View 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 };

35
bin/data/profile/index.ts Normal file
View 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 };