Skip to content

Commit

Permalink
finalize implementation of Directus as CMS for pages
Browse files Browse the repository at this point in the history
  • Loading branch information
unixfy committed Oct 24, 2024
1 parent fd1e7ac commit b2c1b73
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/routes/[slug]/+page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { error } from "@sveltejs/kit";
export async function load({ fetch, params }) {
const directus = getDirectusInstance(fetch);

const page_req = await directus.request(readItems('pages', { fields: ["title", "subtitle", "content", "slug", "date_updated"], filter: { slug: params.slug }, limit: 1 }));
const page_req = await directus.request(readItems('pages', { fields: ["title", "subtitle", "content_html", "slug", "date_updated"], filter: { slug: params.slug }, limit: 1 }));

if (page_req.length === 0) {
error(404, "Page not found in CMS")
Expand Down
12 changes: 7 additions & 5 deletions src/routes/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
</div>

<div class="dark:bg-gray-900 dark:text-white min-h-[80vh]">
<div class="p-8 lg:p-16 max-w-screen-lg m-auto">
<div class="flex flex-col space-y-4 text-lg page-content-container">
{@html JSON.stringify(data.page.content)}
</div>
</div>
<div class="p-8 max-w-screen-lg m-auto">
<div class="flex flex-col space-y-4 text-lg page-content-container">
{#if data.page.content_html}
{@html data.page.content_html}
{/if}
</div>
</div>
</div>

0 comments on commit b2c1b73

Please sign in to comment.