Skip to content

Commit

Permalink
Shift structure into monorepo (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
gherkster committed Feb 25, 2024
1 parent bbcee39 commit 772ac47
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 17 deletions.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions common/composables/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./useRecipeFormatter";
11 changes: 11 additions & 0 deletions common/composables/useRecipeFormatter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ServerIngredient } from "../types/serverRecipe";

export function useRecipeFormatter() {
return {
formatIngredient(ingredient: ServerIngredient) {
const value = `${ingredient.amount}${ingredient.unit} ${ingredient.name} ${ingredient.note}`;

return value.trim();
},
};
}
6 changes: 6 additions & 0 deletions common/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "common",
"version": "1.0.0",
"dependencies": {
}
}
9 changes: 9 additions & 0 deletions common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"rootDir": ".",
"composite": true
},
"references": []
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface ServerIngredientGroup {
ingredients: ServerIngredient[];
}

interface ServerIngredient {
export interface ServerIngredient {
unit?: string;
name: string;
note?: string;
Expand Down
3 changes: 2 additions & 1 deletion website/components/RecipeSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<script setup lang="ts">
import MiniSearch from "minisearch";
import { ServerRecipe } from "~/types/serverRecipe";
import { ServerRecipe } from "common/types/serverRecipe";
import { searchIndexSettings } from "~/types/searchIndex";
const loadIndex = import("@/assets/search-index.json");
Expand All @@ -19,6 +19,7 @@ loadIndex.then((index) => {
function testSearch(event) {
const value = event.target.value;
// TODO: Check if still loading and spin until finished
if (!miniSearch.value) {
return [];
}
Expand Down
4 changes: 2 additions & 2 deletions website/composables/useDirectus.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createDirectus, readItems, rest, RestClient } from "@directus/sdk";
import { ServerRecipe } from "~/types/serverRecipe";
import { GlobalSettings } from "~/types/global";
import { ServerRecipe } from "common/types/serverRecipe";
import { GlobalSettings } from "common/types/global";

export interface CmsSchema {
global: GlobalSettings[];
Expand Down
2 changes: 1 addition & 1 deletion website/mapping/recipeMapper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ServerRecipe } from "~/types/serverRecipe";
import { ServerRecipe } from "common/types/serverRecipe";
import { Recipe } from "~/types/recipe";
import Fraction from "fraction.js";

Expand Down
7 changes: 5 additions & 2 deletions website/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import * as fs from "fs/promises";
import MiniSearch from "minisearch";
import { SearchIndexIndexed, searchIndexSettings } from "./types/searchIndex";

import { ServerRecipe } from "~/types/serverRecipe";
import { ServerRecipe } from "common/types/serverRecipe";
import visualizer from "rollup-plugin-visualizer";
import { fileURLToPath } from "url";

const baseUrl = process.env.NUXT_BASE_URL;
const recipes: ServerRecipe[] = [];
Expand All @@ -18,6 +19,9 @@ export default defineNuxtConfig({
}),
],
},
alias: {
common: fileURLToPath(new URL("../common", import.meta.url)),
},
hooks: {
async "prerender:routes"({ routes }) {
await loadAllRecipes();
Expand All @@ -34,7 +38,6 @@ async function loadAllRecipes() {
console.log(`Loading recipes from ${baseUrl}`);
const client = useDirectus();


const remoteRecipes = await client.getAllRecipes();

remoteRecipes.forEach((r) => {
Expand Down
9 changes: 0 additions & 9 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,7 @@
"devDependencies": {
"@cloudflare/workers-types": "^4.20231010.0",
"@types/node": "^18.16.19",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"@vue/eslint-config-prettier": "^8.0.0",
"@vue/eslint-config-typescript": "^11.0.3",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-vue": "^9.15.1",
"nuxt": "^3.7.4",
"prettier": "^3.0.0",
"rollup-plugin-visualizer": "^5.9.2",
"sass": "^1.64.1",
"typescript": "5.0.4",
Expand Down
2 changes: 1 addition & 1 deletion website/types/searchIndex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ServerRecipe } from "~/types/serverRecipe";
import { ServerRecipe } from "common/types/serverRecipe";
import { Options } from "minisearch";

export type SearchIndexIndexed = Pick<ServerRecipe, "title">;
Expand Down

0 comments on commit 772ac47

Please sign in to comment.