mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 10:51:36 +01:00
Add categories for docs template
This commit is contained in:
@@ -85,7 +85,6 @@ export const actions: Actions = {
|
||||
},
|
||||
body: JSON.stringify({
|
||||
website_id: params.websiteId,
|
||||
user_id: locals.user.id,
|
||||
title: data.get("title")
|
||||
})
|
||||
});
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
<WebsiteEditor
|
||||
id={data.website.id}
|
||||
contentType={data.website.content_type}
|
||||
title={data.website.title}
|
||||
previewContent={data.home.main_content}
|
||||
>
|
||||
|
||||
@@ -11,10 +11,22 @@ export const load: PageServerLoad = async ({ parent, params, cookies, fetch }) =
|
||||
}
|
||||
});
|
||||
|
||||
const categoryData = await fetch(
|
||||
`${API_BASE_PREFIX}/docs_category?website_id=eq.${params.websiteId}&order=category_weight.desc`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${cookies.get("session_token")}`
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const article = await articleData.json();
|
||||
const categories = await categoryData.json();
|
||||
const { website } = await parent();
|
||||
|
||||
return { website, article, API_BASE_PREFIX };
|
||||
return { website, article, categories, API_BASE_PREFIX };
|
||||
};
|
||||
|
||||
export const actions: Actions = {
|
||||
@@ -53,7 +65,8 @@ export const actions: Actions = {
|
||||
meta_author: data.get("author"),
|
||||
cover_image: uploadedImage.file_id,
|
||||
publication_date: data.get("publication-date"),
|
||||
main_content: data.get("main-content")
|
||||
main_content: data.get("main-content"),
|
||||
category: data.get("category")
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
<WebsiteEditor
|
||||
id={data.website.id}
|
||||
contentType={data.website.content_type}
|
||||
title={data.website.title}
|
||||
previewContent={previewContent ||
|
||||
"Put some markdown content in main content to see a live preview here"}
|
||||
@@ -50,6 +51,17 @@
|
||||
};
|
||||
}}
|
||||
>
|
||||
{#if data.website.content_type === "Docs"}
|
||||
<label>
|
||||
Category:
|
||||
<select name="category">
|
||||
{#each data.categories as { id, category_name }}
|
||||
<option value={id} selected={id === data.article.category}>{category_name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</label>
|
||||
{/if}
|
||||
|
||||
<label>
|
||||
Title:
|
||||
<input
|
||||
|
||||
Reference in New Issue
Block a user