diff --git a/mdsvex.config.js b/mdsvex.config.js index 5cdd1d0..79fcd73 100644 --- a/mdsvex.config.js +++ b/mdsvex.config.js @@ -2,6 +2,9 @@ import { defineMDSveXConfig as defineConfig } from "mdsvex"; const config = defineConfig({ extensions: [".svelte.md", ".md", ".svx"], + layout: { + guides: 'src/routes/guides/guides.svelte' + }, smartypants: { dashes: "oldschool", @@ -11,4 +14,4 @@ const config = defineConfig({ rehypePlugins: [], }); -export default config; +export default config; \ No newline at end of file diff --git a/public/favicon/android-chrome-192x192.png b/public/favicon/android-chrome-192x192.png deleted file mode 100644 index e9985ab..0000000 Binary files a/public/favicon/android-chrome-192x192.png and /dev/null differ diff --git a/public/favicon/android-chrome-512x512.png b/public/favicon/android-chrome-512x512.png deleted file mode 100644 index 6a0df75..0000000 Binary files a/public/favicon/android-chrome-512x512.png and /dev/null differ diff --git a/public/favicon/apple-touch-icon.png b/public/favicon/apple-touch-icon.png deleted file mode 100644 index 1027e2d..0000000 Binary files a/public/favicon/apple-touch-icon.png and /dev/null differ diff --git a/public/favicon/browserconfig.xml b/public/favicon/browserconfig.xml deleted file mode 100644 index 249c5c1..0000000 --- a/public/favicon/browserconfig.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - #ffc40d - - - diff --git a/public/favicon/favicon-16x16.png b/public/favicon/favicon-16x16.png deleted file mode 100644 index 4342fa8..0000000 Binary files a/public/favicon/favicon-16x16.png and /dev/null differ diff --git a/public/favicon/favicon-32x32.png b/public/favicon/favicon-32x32.png deleted file mode 100644 index 8b1cbb4..0000000 Binary files a/public/favicon/favicon-32x32.png and /dev/null differ diff --git a/public/favicon/mstile-150x150.png b/public/favicon/mstile-150x150.png deleted file mode 100644 index b0ed3a2..0000000 Binary files a/public/favicon/mstile-150x150.png and /dev/null differ diff --git a/public/favicon/safari-pinned-tab.svg b/public/favicon/safari-pinned-tab.svg deleted file mode 100644 index 1c267ef..0000000 --- a/public/favicon/safari-pinned-tab.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - -Created by potrace 1.14, written by Peter Selinger 2001-2017 - - - - - diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 54cb0c8..68e0ef3 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -5,9 +5,20 @@ export const shuffleArray = (array: any[]) => { } }; -function changePage(pages: any, pageName: string): void { - const pageKey = pageName.toLowerCase(); - if (pages[pageKey as keyof typeof pages]) { - active_page = pages[pageKey as keyof typeof pages]; - } -} +export const fetchMarkdownGuides = async () => { +const allPostFiles = import.meta.glob('/src/routes/guides/*.md'); +const iterablePostFiles = Object.entries(allPostFiles); + +const allPosts = await Promise.all( + iterablePostFiles.map(async ([path, resolver]) => { + const { metadata } = await (resolver() as Promise<{ metadata: any }>); + const postPath = path.slice(11, -3); + return { + meta: metadata, + path: postPath + }; + }) +); + + return allPosts; +}; diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 5c2ede9..13d0dae 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -10,8 +10,7 @@ livecoding.fr + >livecoding.fr diff --git a/src/routes/api/guides/+server.ts b/src/routes/api/guides/+server.ts new file mode 100644 index 0000000..d49673f --- /dev/null +++ b/src/routes/api/guides/+server.ts @@ -0,0 +1,12 @@ +import { fetchMarkdownGuides } from '$lib/utils'; +import { json } from '@sveltejs/kit'; + +export const GET = async () => { + const allPosts = await fetchMarkdownGuides(); + + const sortedPosts = allPosts.sort((a, b) => { + return new Date(b.meta.date).getTime() - new Date(a.meta.date).getTime(); + }); + + return json(sortedPosts); +}; diff --git a/src/routes/guides/+page.svelte b/src/routes/guides/+page.svelte new file mode 100644 index 0000000..a3406cc --- /dev/null +++ b/src/routes/guides/+page.svelte @@ -0,0 +1,18 @@ + + +Blog + + + {#each data.guides as post} + + + + {post.meta.title} + + + Publié le : {post.meta.date} par {post.meta.author} + + {/each} + diff --git a/src/routes/guides/+page.svelte.md b/src/routes/guides/+page.svelte.md deleted file mode 100644 index 8b5f4df..0000000 --- a/src/routes/guides/+page.svelte.md +++ /dev/null @@ -1,8 +0,0 @@ - - Guides - - -# Guides - -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla nec odio et -quam. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla nec. \ No newline at end of file diff --git a/src/routes/guides/+page.ts b/src/routes/guides/+page.ts new file mode 100644 index 0000000..a342ea6 --- /dev/null +++ b/src/routes/guides/+page.ts @@ -0,0 +1,8 @@ +export const load = async ({ fetch }) => { + const response = await fetch(`/api/guides`); + const guides = await response.json(); + + return { + guides + }; +}; \ No newline at end of file diff --git a/src/routes/guides/[slug]/+page.svelte b/src/routes/guides/[slug]/+page.svelte new file mode 100644 index 0000000..b960d5f --- /dev/null +++ b/src/routes/guides/[slug]/+page.svelte @@ -0,0 +1,12 @@ + + + + {data.title} + + Publié le : {data.date} + Auteur : {data.author} + + + \ No newline at end of file diff --git a/src/routes/guides/[slug]/+page.ts b/src/routes/guides/[slug]/+page.ts new file mode 100644 index 0000000..907387c --- /dev/null +++ b/src/routes/guides/[slug]/+page.ts @@ -0,0 +1,11 @@ +export async function load({ params }) { + const post = await import(`../${params.slug}.md`); + const { title, date, author} = post.metadata; + const content = post.default; + return { + content, + title, + date, + author + }; +} \ No newline at end of file diff --git a/src/routes/guides/guides.svelte b/src/routes/guides/guides.svelte new file mode 100644 index 0000000..f58b854 --- /dev/null +++ b/src/routes/guides/guides.svelte @@ -0,0 +1,10 @@ + + + + {title} + \ No newline at end of file diff --git a/src/routes/guides/one.md b/src/routes/guides/one.md new file mode 100644 index 0000000..183102c --- /dev/null +++ b/src/routes/guides/one.md @@ -0,0 +1,7 @@ +--- +title: Premier article +date: '2023-12-22' +author: "Raphaël Maurice Forment" +--- + +Premier article \ No newline at end of file diff --git a/src/routes/guides/three.md b/src/routes/guides/three.md new file mode 100644 index 0000000..77642ce --- /dev/null +++ b/src/routes/guides/three.md @@ -0,0 +1,7 @@ +--- +title: Troisième article +date: '2022-12-14' +author: "Raphaël Maurice Forment" +--- + +Troisième article \ No newline at end of file diff --git a/src/routes/guides/two.md b/src/routes/guides/two.md new file mode 100644 index 0000000..cdd7a9b --- /dev/null +++ b/src/routes/guides/two.md @@ -0,0 +1,7 @@ +--- +title: Deuxième article +date: '2022-12-14' +author: "Raphaël Maurice Forment" +--- + +Second article \ No newline at end of file diff --git a/src/routes/posts/+page.svelte b/src/routes/posts/+page.svelte deleted file mode 100644 index 61fa696..0000000 --- a/src/routes/posts/+page.svelte +++ /dev/null @@ -1,187 +0,0 @@ - - - - - - - changePage("Accueil")} - class="text-3xl font-extrabold text-transparent bg-clip-text bg-gradient-to-r from-orange-300 to-orange-200 uppercase" - >livecoding.fr - - - - - - - - - - - - - changePage("Evenements")} - class="text-gray-100 hover:text-orange-300 flex md:hidden" - >Évènements - changePage("Membres")} - class="text-gray-100 hover:text-orange-300 flex md:hidden">Membres - changePage("Outils")} - class="text-gray-100 hover:text-orange-300 flex md:hidden">Outils - changePage("Réseaux")} - class="text-gray-100 hover:text-orange-300 flex md:hidden">Réseaux - changePage("Ressources")} - class="text-gray-100 hover:text-orange-300 flex md:hidden" - >Ressources - changePage("Presse")} - class="text-gray-100 hover:text-orange-300 flex md:hidden">Presse - changePage("Contact")} - class="text-gray-100 hover:text-orange-300 flex md:hidden">Contact - - - - - - - - - - - - - - - - changePage("Evenements")}>Évènements - - - changePage("Membres")}>Membres - - - changePage("Outils")}>Outils - - - changePage("Réseaux")}>Réseaux - - - changePage("Ressources")}>Ressources - - - - changePage("Presse")}>Presse - - - changePage("Contact")}>Contact - - - - - - -
Publié le : {post.meta.date} par {post.meta.author}
Publié le : {data.date}
Auteur : {data.author}