diff --git a/scripts/jsonGenerator.js b/scripts/jsonGenerator.js index f63091a..f46ba22 100644 --- a/scripts/jsonGenerator.js +++ b/scripts/jsonGenerator.js @@ -9,11 +9,12 @@ const CONTENT_DEPTH = 3; const BLOG_FOLDER = "blog"; // get data from markdown -const getData = (folder, groupDepth) => { +const getData = (folder, groupDepth, langIndex = 0) => { // get paths const getPaths = languages - .map((lang) => { - const dir = path.join(CONTENT_ROOT, lang.contentDir, folder); + .map((lang, index) => { + const langFolder = lang.contentDir ? lang.contentDir : lang.languageCode; + const dir = path.join(CONTENT_ROOT, folder, langFolder); return fs .readdirSync(dir) .filter( @@ -27,7 +28,7 @@ const getData = (folder, groupDepth) => { const isFolder = stats.isDirectory(); if (isFolder) { - return getData(filepath, groupDepth); + return getData(filepath, groupDepth, index); } else { const file = fs.readFileSync(filepath, "utf-8"); const { data, content } = matter(file); @@ -41,7 +42,7 @@ const getData = (folder, groupDepth) => { const group = pathParts[groupDepth]; return { - lang: lang.languageCode, + lang: languages[langIndex].languageCode, group: group, slug: slug, frontmatter: data, diff --git a/src/config/config.json b/src/config/config.json index 83920f1..f695a6e 100755 --- a/src/config/config.json +++ b/src/config/config.json @@ -3,7 +3,7 @@ "title": "Astroplate", "base_url": "https://astroplate.netlify.app", "base_path": "/", - "trailing_slash": false, + "trailing_slash": true, "favicon": "/images/favicon.png", "logo": "/images/logo.png", "logo_darkmode": "/images/logo-darkmode.png", diff --git a/src/content/about/config.ts b/src/content/about/config.ts new file mode 100755 index 0000000..71ddbf1 --- /dev/null +++ b/src/content/about/config.ts @@ -0,0 +1,11 @@ +import { z } from "zod"; + +const AboutSchema = z.object({ + title: z.string(), + meta_title: z.string().optional(), + description: z.string().optional(), + image: z.string(), + draft: z.boolean().optional(), +}); + +export default AboutSchema; diff --git a/src/content/english/about/-index.md b/src/content/about/english/-index.md similarity index 100% rename from src/content/english/about/-index.md rename to src/content/about/english/-index.md diff --git a/src/content/french/about/-index.md b/src/content/about/french/-index.md similarity index 92% rename from src/content/french/about/-index.md rename to src/content/about/french/-index.md index a4ac128..041c6ad 100644 --- a/src/content/french/about/-index.md +++ b/src/content/about/french/-index.md @@ -6,4 +6,4 @@ image: "/images/avatar.png" draft: false --- -L'entreprise elle-même est une entreprise très prospère. Ils ne connaissent pas les bienfaits du corps, ou sauf qu'ils le recevront à d'autres moments, le tout, les temps de travail, qu'il déteste à partir de ce moment mais. Il fuit les plaisirs perçus pour être supposés n'être rien, tout ou, et la douleur est ce qui est la plus grande option, car cela lui est facile, et avec ce que cela s'ensuit, ils lui procurent de la douleur et ainsi de suite ! Car ledit expédient de la vérité repousse le plaisir et empêche la douleur, ils fournissent comme si \ No newline at end of file +L'entreprise elle-même est une entreprise très prospère. Ils ne connaissent pas les bienfaits du corps, ou sauf qu'ils le recevront à d'autres moments, le tout, les temps de travail, qu'il déteste à partir de ce moment mais. Il fuit les plaisirs perçus pour être supposés n'être rien, tout ou, et la douleur est ce qui est la plus grande option, car cela lui est facile, et avec ce que cela s'ensuit, ils lui procurent de la douleur et ainsi de suite ! Car ledit expédient de la vérité repousse le plaisir et empêche la douleur, ils fournissent comme si diff --git a/src/content/authors/config.ts b/src/content/authors/config.ts new file mode 100755 index 0000000..d0eb2e1 --- /dev/null +++ b/src/content/authors/config.ts @@ -0,0 +1,29 @@ +import { defineCollection, z } from "astro:content"; + +// Author collection schema +const authorsCollection = defineCollection({ + schema: z.object({ + title: z.string(), + meta_title: z.string().optional(), + email: z.string().optional(), + image: z.string().optional(), + description: z.string().optional(), + social: z + .array( + z + .object({ + name: z.string().optional(), + icon: z.string().optional(), + link: z.string().optional(), + }) + .optional(), + ) + .optional(), + draft: z.boolean().optional(), + }), +}); + +// Export collections +export const collections = { + authors: authorsCollection, +}; diff --git a/src/content/english/authors/-index.md b/src/content/authors/english/-index.md similarity index 100% rename from src/content/english/authors/-index.md rename to src/content/authors/english/-index.md diff --git a/src/content/english/authors/john-doe.md b/src/content/authors/english/john-doe.md similarity index 100% rename from src/content/english/authors/john-doe.md rename to src/content/authors/english/john-doe.md diff --git a/src/content/english/authors/sam-wilson.md b/src/content/authors/english/sam-wilson.md similarity index 100% rename from src/content/english/authors/sam-wilson.md rename to src/content/authors/english/sam-wilson.md diff --git a/src/content/english/authors/william-jacob.md b/src/content/authors/english/william-jacob.md similarity index 100% rename from src/content/english/authors/william-jacob.md rename to src/content/authors/english/william-jacob.md diff --git a/src/content/french/authors/-index.md b/src/content/authors/french/-index.md similarity index 100% rename from src/content/french/authors/-index.md rename to src/content/authors/french/-index.md diff --git a/src/content/french/authors/john-doe.md b/src/content/authors/french/john-doe.md similarity index 100% rename from src/content/french/authors/john-doe.md rename to src/content/authors/french/john-doe.md diff --git a/src/content/french/authors/sam-wilson.md b/src/content/authors/french/sam-wilson.md similarity index 100% rename from src/content/french/authors/sam-wilson.md rename to src/content/authors/french/sam-wilson.md diff --git a/src/content/french/authors/william-jacob.md b/src/content/authors/french/william-jacob.md similarity index 100% rename from src/content/french/authors/william-jacob.md rename to src/content/authors/french/william-jacob.md diff --git a/src/content/blog/config.ts b/src/content/blog/config.ts new file mode 100755 index 0000000..e2f906b --- /dev/null +++ b/src/content/blog/config.ts @@ -0,0 +1,33 @@ +import { defineCollection, z } from "astro:content"; + +// Post collection schema +const blogCollection = defineCollection({ + schema: z.object({ + title: z.string(), + meta_title: z.string().optional(), + description: z.string().optional(), + date: z.date().optional(), + image: z.string().optional(), + author: z.string().default("Admin"), + categories: z.array(z.string()).default(["others"]), + tags: z.array(z.string()).default(["others"]), + draft: z.boolean().optional(), + }), +}); + +// Pages collection schema +const pagesCollection = defineCollection({ + schema: z.object({ + title: z.string(), + meta_title: z.string().optional(), + description: z.string().optional(), + image: z.string().optional(), + draft: z.boolean().optional(), + }), +}); + +// Export collections +export const collections = { + blog: blogCollection, + pages: pagesCollection, +}; diff --git a/src/content/english/blog/-index.md b/src/content/blog/english/-index.md similarity index 100% rename from src/content/english/blog/-index.md rename to src/content/blog/english/-index.md diff --git a/src/content/english/blog/post-1.md b/src/content/blog/english/post-1.md similarity index 100% rename from src/content/english/blog/post-1.md rename to src/content/blog/english/post-1.md diff --git a/src/content/english/blog/post-2.md b/src/content/blog/english/post-2.md similarity index 100% rename from src/content/english/blog/post-2.md rename to src/content/blog/english/post-2.md diff --git a/src/content/english/blog/post-3.md b/src/content/blog/english/post-3.md similarity index 100% rename from src/content/english/blog/post-3.md rename to src/content/blog/english/post-3.md diff --git a/src/content/english/blog/post-4.md b/src/content/blog/english/post-4.md similarity index 100% rename from src/content/english/blog/post-4.md rename to src/content/blog/english/post-4.md diff --git a/src/content/french/blog/-index.md b/src/content/blog/french/-index.md similarity index 100% rename from src/content/french/blog/-index.md rename to src/content/blog/french/-index.md diff --git a/src/content/french/blog/post-1.md b/src/content/blog/french/post-1.md similarity index 100% rename from src/content/french/blog/post-1.md rename to src/content/blog/french/post-1.md diff --git a/src/content/french/blog/post-2.md b/src/content/blog/french/post-2.md similarity index 100% rename from src/content/french/blog/post-2.md rename to src/content/blog/french/post-2.md diff --git a/src/content/french/blog/post-3.md b/src/content/blog/french/post-3.md similarity index 100% rename from src/content/french/blog/post-3.md rename to src/content/blog/french/post-3.md diff --git a/src/content/french/blog/post-4.md b/src/content/blog/french/post-4.md similarity index 100% rename from src/content/french/blog/post-4.md rename to src/content/blog/french/post-4.md diff --git a/src/content/contact/config.ts b/src/content/contact/config.ts new file mode 100755 index 0000000..349b955 --- /dev/null +++ b/src/content/contact/config.ts @@ -0,0 +1,14 @@ +import { defineCollection, z } from "astro:content"; + +const contactCollection = defineCollection({ + schema: z.object({ + title: z.string(), + meta_title: z.string().optional(), + description: z.string(), + draft: z.boolean().optional(), + }), +}); + +export const collections = { + contact: contactCollection, +}; diff --git a/src/content/english/contact/-index.md b/src/content/contact/english/-index.md similarity index 100% rename from src/content/english/contact/-index.md rename to src/content/contact/english/-index.md diff --git a/src/content/french/contact/-index.md b/src/content/contact/french/-index.md similarity index 100% rename from src/content/french/contact/-index.md rename to src/content/contact/french/-index.md diff --git a/src/content/homepage/config.ts b/src/content/homepage/config.ts new file mode 100755 index 0000000..0262957 --- /dev/null +++ b/src/content/homepage/config.ts @@ -0,0 +1,42 @@ +import { defineCollection, z } from "astro:content"; + +// Banner schema +const bannerSchema = z.object({ + title: z.string(), + content: z.string(), + image: z.string(), + button: z.object({ + enable: z.boolean(), + label: z.string(), + link: z.string(), + }), +}); + +// Features schema +const featureSchema = z.object({ + title: z.string(), + image: z.string(), + content: z.string(), + bulletpoints: z.array(z.string()), + button: z.object({ + enable: z.boolean(), + label: z.string().optional(), + link: z.string().optional(), + }), +}); + +// Main content schema +const contentSchema = z.object({ + banner: bannerSchema, + features: z.array(featureSchema), +}); + +// Define the collection +const contentCollection = defineCollection({ + schema: contentSchema, +}); + +// Export collections +export const collections = { + content: contentCollection, +}; diff --git a/src/content/english/homepage/-index.md b/src/content/homepage/english/-index.md similarity index 100% rename from src/content/english/homepage/-index.md rename to src/content/homepage/english/-index.md diff --git a/src/content/french/homepage/-index.md b/src/content/homepage/french/-index.md similarity index 99% rename from src/content/french/homepage/-index.md rename to src/content/homepage/french/-index.md index d02c12b..be96b3f 100755 --- a/src/content/french/homepage/-index.md +++ b/src/content/homepage/french/-index.md @@ -50,4 +50,4 @@ features: enable: false label: "" link: "" ---- \ No newline at end of file +--- diff --git a/src/content/pages/config.ts b/src/content/pages/config.ts new file mode 100755 index 0000000..b159fc5 --- /dev/null +++ b/src/content/pages/config.ts @@ -0,0 +1,24 @@ +import { defineCollection, z } from "astro:content"; + +const elementsCollection = defineCollection({ + schema: z.object({ + title: z.string(), + meta_title: z.string().optional(), + description: z.string(), + draft: z.boolean().optional(), + }), +}); + +const privacyCollection = defineCollection({ + schema: z.object({ + title: z.string(), + meta_title: z.string().optional(), + description: z.string(), + draft: z.boolean().optional(), + }), +}); + +export const collections = { + elements: elementsCollection, + privacy: privacyCollection, +}; diff --git a/src/content/english/pages/elements.mdx b/src/content/pages/english/elements.mdx similarity index 100% rename from src/content/english/pages/elements.mdx rename to src/content/pages/english/elements.mdx diff --git a/src/content/english/pages/privacy-policy.md b/src/content/pages/english/privacy-policy.md similarity index 100% rename from src/content/english/pages/privacy-policy.md rename to src/content/pages/english/privacy-policy.md diff --git a/src/content/french/pages/elements.mdx b/src/content/pages/french/elements.mdx similarity index 100% rename from src/content/french/pages/elements.mdx rename to src/content/pages/french/elements.mdx diff --git a/src/content/french/pages/privacy-policy.md b/src/content/pages/french/privacy-policy.md similarity index 100% rename from src/content/french/pages/privacy-policy.md rename to src/content/pages/french/privacy-policy.md diff --git a/src/content/sections/config.ts b/src/content/sections/config.ts new file mode 100755 index 0000000..1f49900 --- /dev/null +++ b/src/content/sections/config.ts @@ -0,0 +1,28 @@ +import { z } from "zod"; + +const TestimonialSchema = z.object({ + name: z.string(), + designation: z.string(), + avatar: z.string(), + content: z.string(), +}); + +const TestimonialsSchema = z.array(TestimonialSchema); + +const CallToActionSchema = z.object({ + enable: z.boolean(), + title: z.string(), + image: z.string(), + description: z.string(), + button: z.object({ + enable: z.boolean(), + label: z.string(), + link: z.string().url(), + }), +}); + +export const collections = { + Testimonial: TestimonialSchema, + Testimonials: TestimonialsSchema, + CallToAction: CallToActionSchema, +}; diff --git a/src/content/english/sections/call-to-action.md b/src/content/sections/english/call-to-action.md similarity index 100% rename from src/content/english/sections/call-to-action.md rename to src/content/sections/english/call-to-action.md diff --git a/src/content/english/sections/testimonial.md b/src/content/sections/english/testimonial.md similarity index 100% rename from src/content/english/sections/testimonial.md rename to src/content/sections/english/testimonial.md diff --git a/src/content/french/sections/call-to-action.md b/src/content/sections/french/call-to-action.md similarity index 100% rename from src/content/french/sections/call-to-action.md rename to src/content/sections/french/call-to-action.md diff --git a/src/content/french/sections/testimonial.md b/src/content/sections/french/testimonial.md similarity index 100% rename from src/content/french/sections/testimonial.md rename to src/content/sections/french/testimonial.md diff --git a/src/layouts/components/BlogCard.astro b/src/layouts/components/BlogCard.astro index d2a8a89..eb15361 100644 --- a/src/layouts/components/BlogCard.astro +++ b/src/layouts/components/BlogCard.astro @@ -18,6 +18,11 @@ const { title, image, date, author, categories } = data.data; const lang = getLangFromUrl(Astro.url); const { read_more } = await getTranslations(lang as keyof ContentEntryMap); + +const slugParts = data.slug.split("/"); +slugParts[0] = "blog"; +const modifiedSlug = slugParts.join("/"); +data.slug = modifiedSlug; ---