diff --git a/resources/newssite/news-nuxt/composables/provide-locale.js b/resources/newssite/news-nuxt/composables/provide-locale.js index 6f9ffe5de..47db4614b 100644 --- a/resources/newssite/news-nuxt/composables/provide-locale.js +++ b/resources/newssite/news-nuxt/composables/provide-locale.js @@ -2,6 +2,8 @@ import { provide } from "vue"; import { useHead } from "#imports"; import { dataSource } from "../data"; +import { v4 as uuidv4 } from "uuid"; + const RTL_LOCALES = ["ar", "he", "fa", "ps", "ur"]; const DEFAULT_LANG = "en"; const DEFAULT_DIR = "ltr"; @@ -16,10 +18,41 @@ export function provideLocale() { htmlAttrs: { dir, lang }, }); + const { content } = dataSource[lang]; + + // Generate unique IDs for all articles, and their content items where appropriate. + const contentWithIds = Object.create(null); + Object.keys(content).forEach((key) => { + const { sections } = content[key]; + + const currentSections = sections.map((section) => { + const currentSection = { ...section }; + currentSection.articles = section.articles.map((article) => { + const currentArticle = { ...article }; + currentArticle.id = uuidv4(); + if (Array.isArray(article.content)) { + currentArticle.content = article.content.map((item) => { + const currentItem = { ...item }; + currentItem.id = uuidv4(); + return currentItem; + }); + } + return currentArticle; + }); + return currentSection; + }); + + contentWithIds[key] = { + ...content[key], + sections: currentSections, + }; + }); + const value = { lang, dir, ...dataSource[lang], + content: contentWithIds, }; provide("data", value); diff --git a/resources/newssite/news-nuxt/dist/404.html b/resources/newssite/news-nuxt/dist/404.html index 4c3f62666..dfbb17dc6 100644 --- a/resources/newssite/news-nuxt/dist/404.html +++ b/resources/newssite/news-nuxt/dist/404.html @@ -3,6 +3,6 @@