diff --git a/package-lock.json b/package-lock.json index 1841b8c..45954dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,9 @@ "name": "pdc-b2b", "version": "0.0.0", "dependencies": { + "dayjs": "^1.11.13", "pinia": "^2.1.7", + "slugify": "^1.6.6", "vue": "^3.4.29" }, "devDependencies": { @@ -728,6 +730,11 @@ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" }, + "node_modules/dayjs": { + "version": "1.11.13", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.13.tgz", + "integrity": "sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==" + }, "node_modules/entities": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", @@ -938,6 +945,14 @@ "fsevents": "~2.3.2" } }, + "node_modules/slugify": { + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/slugify/-/slugify-1.6.6.tgz", + "integrity": "sha512-h+z7HKHYXj6wJU+AnS/+IH8Uh9fdcX1Lrhg1/VMdf9PwoBQXFcXiAdsy2tSK0P6gKwJLXp02r90ahUCqHk9rrw==", + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/source-map-js": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", diff --git a/package.json b/package.json index 2e02e65..79f0136 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,9 @@ "preview": "vite preview" }, "dependencies": { + "dayjs": "^1.11.13", "pinia": "^2.1.7", + "slugify": "^1.6.6", "vue": "^3.4.29" }, "devDependencies": { diff --git a/public/site/templates/projects.json.php b/public/site/templates/projects.json.php new file mode 100644 index 0000000..9fb540f --- /dev/null +++ b/public/site/templates/projects.json.php @@ -0,0 +1,18 @@ +children()->map(function ($child) { + return [ + 'title' => $child->title()->value(), + 'url' => $child->url(), + 'modified' => $child->modified('Y-m-d'), + 'status' => $child->status() + ]; +})->values(); + +$specificData = [ + "children" => $children, +]; + +$data = array_merge($genericData, $specificData); + +echo json_encode($data); diff --git a/public/site/templates/projects.php b/public/site/templates/projects.php new file mode 100644 index 0000000..4ed6305 --- /dev/null +++ b/public/site/templates/projects.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/Project.vue b/src/components/Project.vue new file mode 100644 index 0000000..fad22d3 --- /dev/null +++ b/src/components/Project.vue @@ -0,0 +1,154 @@ + + + + + diff --git a/src/components/Projects.vue b/src/components/Projects.vue new file mode 100644 index 0000000..5e42584 --- /dev/null +++ b/src/components/Projects.vue @@ -0,0 +1,24 @@ + + + + diff --git a/src/components/TabPanel.vue b/src/components/TabPanel.vue new file mode 100644 index 0000000..1917cbe --- /dev/null +++ b/src/components/TabPanel.vue @@ -0,0 +1,47 @@ + + + diff --git a/src/components/Tabs.vue b/src/components/Tabs.vue new file mode 100644 index 0000000..0f05870 --- /dev/null +++ b/src/components/Tabs.vue @@ -0,0 +1,116 @@ + + + + + diff --git a/src/stores/api.js b/src/stores/api.js index 9774a37..f3aaad7 100644 --- a/src/stores/api.js +++ b/src/stores/api.js @@ -1,11 +1,40 @@ import { defineStore } from "pinia"; export const useApiStore = defineStore("counter", () => { - async function fetchPageData() { - const isHomePage = window.location.pathname === "/"; + /** + * Asynchronously fetches JSON data corresponding to a given path. + * + * @param {string} [path=window.location.pathname] - The path for which to fetch data. + * - If no path is provided, the function will use the current page's path. + * - If the path is "/", it is assumed to be the homepage, and "home.json" is fetched. + * - For other paths, the function will append ".json" to the path and fetch that URL. + * + * @returns {Promise} A promise that resolves to the JSON data if the fetch is successful. + * + * @throws {Error} Will throw an error if the HTTP request fails (e.g., non-200 status code). + * - The error will include the HTTP status code and a message indicating the fetch failed. + * + * @example + * // Fetch data for the current page + * fetchPageData().then(data => { + * console.log(data); + * }).catch(error => { + * console.error('Error fetching data:', error); + * }); + * + * @example + * // Fetch data for a specific path + * fetchPageData('/about').then(data => { + * console.log(data); + * }).catch(error => { + * console.error('Error fetching data:', error); + * }); + */ + async function fetchPageData(path = window.location.pathname) { + const isHomePage = path === "/"; const url = isHomePage - ? `${window.location.href}home.json` - : `${window.location.href}.json`; + ? `${window.location.origin}/home.json` + : `${window.location.origin}/${path}.json`; try { const response = await fetch(url); @@ -13,10 +42,12 @@ export const useApiStore = defineStore("counter", () => { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); + console.log("Données récupérées du chemin " + path, data); return data; } catch (error) { console.error( - "Une erreur s'est produite lors de la récupération des données :", + "Une erreur s'est produite lors de la récupération des données pour l'URL :", + url, error ); throw error; diff --git a/src/views/Home.vue b/src/views/Home.vue index 8eb8623..564e6c2 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -2,300 +2,18 @@

{{ data.content.title }}

- +
-

Projets

-
- - - -
- -
- -
-
-

Miss Dior Blooming Bouquet

-

- Dernière mise à jour le - -

-
- -
    -
  1. - Votre Brief -
  2. -
-
-
-
-

Miss Dior Blooming Bouquet

-

- Dernière mise à jour le - -

-
- -
    -
  1. - Votre Brief -
  2. -
  3. - Brief Enrichi -
  4. -
  5. - Rendu 360° -
  6. -
-
-
- +
- -