Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions plugin/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,24 @@ async function makePhotos(ctx: PluginContext) {
);
return Promise.all(
infoPaths.map(async (info) => {
const contents = await fs.readFile(info, { encoding: "utf-8" });
const infoPath = path.resolve(info);
ctx.addWatchFile(infoPath);

const contents = await fs.readFile(infoPath, { encoding: "utf-8" });
const match = contents.match(/photo\(\{(?<description>[\S\s]*)\}\);/);
if (match === null) {
throw new Error(`Could not parse ${info}`);
throw new Error(`Could not parse ${infoPath}`);
}
const infoMap = match.groups!["description"];

const infoDir = path.dirname(info);
const infoDir = path.dirname(infoPath);
const dirName = path.basename(infoDir);
const id = dirName.replace(/^\d+-/, "");
idToDirName.set(id, dirName);

const src = path.join(infoDir, CONTENT_PHOTO);
ctx.addWatchFile(src);

const previewWidth = calcWidth(512, await sharp(src).metadata());

// imageOutPath and previewOutPath are
Expand All @@ -137,18 +142,21 @@ async function makePhotos(ctx: PluginContext) {
);
}

async function makePosts(): Promise<string[]> {
async function makePosts(ctx: PluginContext): Promise<string[]> {
const posts: string[] = [];
for await (const info of fs.glob(
path.join("src/Content/blogs", "*", "post.tsx"),
)) {
const contents = await fs.readFile(info, { encoding: "utf-8" });
const infoPath = path.resolve(info);
ctx.addWatchFile(infoPath);

const contents = await fs.readFile(infoPath, { encoding: "utf-8" });
const match = contents.match(/post\(\{(?<description>[\S\s]*)\}\);/);
if (match === null) {
throw new Error(`Could not parse ${info}`);
throw new Error(`Could not parse ${infoPath}`);
}
const infoMap = match.groups!["description"];
const infoDir = path.dirname(info);
const infoDir = path.dirname(infoPath);
const id = path.basename(infoDir);

// TODO: this is awful, I should really use ts parser
Expand Down Expand Up @@ -183,7 +191,7 @@ function contentPlugin(): Plugin {
];

export const posts = [
${(await makePosts()).join(",\n")}
${(await makePosts(this)).join(",\n")}
];

export function post(any) {}
Expand Down
Binary file added src/Content/photos/0021-vienna-rathaus/image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/Content/photos/0021-vienna-rathaus/info.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import photo from "virtual:photo";

photo({
name: "Vienna Rathaus",
camera: "Sony α7c",
lens: "Tamron 28-75mm f2.8 Di III VXD G2",
tags: ["digital", "architecture", "austria"],
});
Binary file added src/Content/photos/0022-sudbahnhotel/image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/Content/photos/0022-sudbahnhotel/info.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import photo from "virtual:photo";

photo({
name: "Südbahnhotel Semmering",
camera: "Sony α7c",
lens: "Tamron 28-75mm f2.8 Di III VXD G2",
tags: ["digital", "architecture", "austria"],
});
Binary file added src/Content/photos/0023-aurum/image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/Content/photos/0023-aurum/info.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import photo from "virtual:photo";

photo({
name: "Aurum",
camera: "Sony α7c",
lens: "Tamron 70-300mm F4.5-6.3 Di III RXD",
tags: ["digital", "architecture", "veliky novgorod"],
});
Binary file added src/Content/photos/0025-axes/image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/Content/photos/0025-axes/info.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import photo from "virtual:photo";

photo({
name: "Axes",
camera: "Minolta Dynax 500si",
lens: "Tamron 28-80 f/3.5-5.6",
film: "Kodacolor vr 200 plus (expired)",
tags: ["film", "architecture", "moscow"],
});
Binary file added src/Content/photos/0026-sandy-cliffs/image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/Content/photos/0026-sandy-cliffs/info.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import photo from "virtual:photo";

photo({
name: "Sandy cliffs",
camera: "Sony α7c",
lens: "Tamron 28-75mm f2.8 Di III VXD G2",
tags: ["digital", "landscape", "lake baikal"],
});
7 changes: 6 additions & 1 deletion src/Virtual/photo.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { JSX } from "solid-js";

declare module "virtual:photo" {
type Medium = "digital" | "film" | "infrared";
type Location = "moscow" | "saint petersburg" | "veliky novgorod";
type Location =
| "moscow"
| "saint petersburg"
| "veliky novgorod"
| "austria"
| "lake baikal";
type Genre =
| "architecture"
| "landscape"
Expand Down