Update Home

2025-06-14 15:29:53 +02:00
parent de69169b5d
commit 2bf34ed624

42
Home.md

@@ -22,9 +22,49 @@ Then this window should pop up ![image](https://git.the1s.de/theis.gaedigk/Cookb
In this window, you can type everything you want!
## How to delete recipes?
Currently there exists no way to delete recipes via an UI.
But you can delete recipes by deleting the recipe file. These files can you find in the recipes directory. To go in that directory you must open the Cookbook folder then go through these directorys: ```backend --> database --> recipes``` or ```/backend/database/recipes```.
In this directory you can find all of the recipes that you have created. They are all stored in ```.txt``` files.
## How to load recipes?
To load recipes, simply click on ![image](https://git.the1s.de/theis.gaedigk/Cookbook/src/branch/imgs/img/sync.png)
## How to edit recipes?
Unfortunatly, there is no UI for editing recipies yet.
## How to edit recipes?
But you can edit your recipes, by going in to the recipes directory. To go in that directory you must open the Cookbook folder then go through these directorys: ```backend --> database --> recipes``` or ```/backend/database/recipes```.
There you will find all of your recipes stored in different ```.txt``` files. The title of your recipe will always be the filename of the ```.txt``` file. The content of your recipes is of course in the ```.txt``` file.
### For instance, here is the model to load the recipes.
[Extract from ```server.js```]([url](https://git.the1s.de/theis.gaedigk/Cookbook/src/branch/main/backend/server.js)) (there is more code below and before):
```js
app.get("/", (req, res) => {
// sync recipes
const recipesFolder = path.join(basePath, "database", "recipes");
if (!fs.existsSync(recipesFolder)) {
fs.mkdirSync(recipesFolder, { recursive: true });
}
fs.readdir(recipesFolder, (err, files) => {
if (err) {
return res.status(500).send("Error by reading recipe files!");
}
const txtFiles = files.filter((file) => file.endsWith(".txt"));
const recipes = txtFiles.map((file) => {
const content = fs.readFileSync(path.join(recipesFolder, file), "utf8");
return {
title: path.basename(file, ".txt"),
content: marked.parse(content),
};
});
res.render("index", { recipes });
});
});
```