This commit is contained in:
Morten Olsen
2023-03-28 08:10:46 +02:00
parent 9b1a067d56
commit 7adf03c83f
44 changed files with 1780 additions and 411 deletions

View File

@@ -1,19 +1,22 @@
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";
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 = {
cwd: string;
pattern: string;
bundler: Bundler;
};
const createArticles = ({ bundler }: ArticleOptions) => {
const createArticles = ({ bundler, cwd, pattern }: ArticleOptions) => {
const files = createGlob({
pattern: "content/articles/**/*.md",
pattern,
cwd,
create: (path) => {
const file = createFile({ path });
const article = file.pipe(async (raw) => {
@@ -27,12 +30,12 @@ const createArticles = ({ bundler }: ArticleOptions) => {
});
const coverUrl = createImage({
image: resolve(cwd, cover),
format: "avif",
format: 'avif',
bundler,
});
const thumbUrl = createImage({
image: resolve(cwd, cover),
format: "avif",
format: 'avif',
width: 400,
bundler,
});

View File

@@ -1,20 +1,24 @@
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";
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 = {
cwd: string;
pattern: string;
bundler: Bundler;
};
const createPositions = ({ bundler }: PositionOptions) => {
const createPositions = ({ cwd, pattern, bundler }: PositionOptions) => {
const files = createGlob<Observable<Position>>({
pattern: "content/resume/positions/**/*.md",
pattern,
cwd,
create: (path) => {
console.log('c', path);
const file = createFile({ path });
const position = file.pipe(async (raw) => {
const { data, content } = grayMatter(raw);

View File

@@ -1,27 +1,29 @@
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";
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 = {
path: string;
cwd: string;
bundler: Bundler;
};
const createProfile = ({ bundler }: ProfileOptions) => {
const createProfile = ({ cwd, path, bundler }: ProfileOptions) => {
const file = createFile({
path: resolve("content/profile.yml"),
path: resolve(cwd, path),
});
const profile = file.pipe(async (yaml) => {
const data = YAML.parse(yaml);
const imagePath = resolve("content", data.image);
const imagePath = resolve('content', data.image);
const result: Profile = {
...data,
imageUrl: createImage({
image: imagePath,
format: "avif",
format: 'webp',
bundler,
}),
imagePath,