From 754b84e5f61e43145a58aa21315919b6d05f23bb Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Tue, 8 Sep 2026 23:34:42 +0200 Subject: [PATCH] temp --- .../article/content-types/article/schema.json | 20 +++- .../content-types/category/schema.json | 14 ++- cms/src/index.ts | 14 +++ frontend/app/app.vue | 5 + frontend/app/components/ArticleCard.vue | 3 +- frontend/app/composables/useLocale.ts | 21 ++++ frontend/app/i18n/strings.ts | 104 ++++++++++++++++++ frontend/app/layouts/default.vue | 69 +++++++++--- frontend/app/pages/blog/[slug].vue | 16 ++- frontend/app/pages/blog/index.vue | 27 +++-- frontend/app/pages/category/[slug].vue | 28 +++-- frontend/app/pages/index.vue | 22 ++-- frontend/server/api/articles/[slug].get.ts | 3 +- frontend/server/api/articles/index.get.ts | 3 +- frontend/server/api/categories/[slug].get.ts | 3 +- frontend/server/api/categories/index.get.ts | 6 +- frontend/server/utils/queries.ts | 5 + frontend/shared/utils/format.ts | 13 ++- 18 files changed, 304 insertions(+), 72 deletions(-) create mode 100644 frontend/app/composables/useLocale.ts create mode 100644 frontend/app/i18n/strings.ts diff --git a/cms/src/api/article/content-types/article/schema.json b/cms/src/api/article/content-types/article/schema.json index 488a18e..8dbee17 100644 --- a/cms/src/api/article/content-types/article/schema.json +++ b/cms/src/api/article/content-types/article/schema.json @@ -11,31 +11,41 @@ "draftAndPublish": true, "populateCreatorFields": true }, + "pluginOptions": { + "i18n": { + "localized": true + } + }, "attributes": { "title": { "type": "string", "required": true, - "maxLength": 160 + "maxLength": 160, + "pluginOptions": { "i18n": { "localized": true } } }, "slug": { "type": "uid", "targetField": "title", - "required": true + "required": true, + "pluginOptions": { "i18n": { "localized": false } } }, "content": { "type": "richtext", - "required": true + "required": true, + "pluginOptions": { "i18n": { "localized": true } } }, "cover": { "type": "media", "multiple": false, - "allowedTypes": ["images"] + "allowedTypes": ["images"], + "pluginOptions": { "i18n": { "localized": false } } }, "category": { "type": "relation", "relation": "manyToOne", "target": "api::category.category", - "inversedBy": "articles" + "inversedBy": "articles", + "pluginOptions": { "i18n": { "localized": false } } } } } diff --git a/cms/src/api/category/content-types/category/schema.json b/cms/src/api/category/content-types/category/schema.json index 2dd1e14..023ad5b 100644 --- a/cms/src/api/category/content-types/category/schema.json +++ b/cms/src/api/category/content-types/category/schema.json @@ -10,22 +10,30 @@ "options": { "draftAndPublish": false }, + "pluginOptions": { + "i18n": { + "localized": true + } + }, "attributes": { "name": { "type": "string", "required": true, - "unique": true + "unique": true, + "pluginOptions": { "i18n": { "localized": true } } }, "slug": { "type": "uid", "targetField": "name", - "required": true + "required": true, + "pluginOptions": { "i18n": { "localized": false } } }, "articles": { "type": "relation", "relation": "oneToMany", "target": "api::article.article", - "mappedBy": "category" + "mappedBy": "category", + "pluginOptions": { "i18n": { "localized": false } } } } } diff --git a/cms/src/index.ts b/cms/src/index.ts index 0e2ff50..a7f3d99 100644 --- a/cms/src/index.ts +++ b/cms/src/index.ts @@ -45,11 +45,25 @@ async function disablePublicSignUp(strapi: Core.Strapi) { } } +/** + * The site content is authored in Italian and English. Strapi ships with only + * the default `it` locale, so the `en` locale is created here if missing. + */ +async function ensureEnglishLocale(strapi: Core.Strapi) { + const locales = strapi.plugin('i18n').service('locales'); + const existing = await locales.find({ where: { code: 'en' } }); + + if (existing.length === 0) { + await locales.create({ code: 'en', name: 'English (en)', isDefault: false }); + } +} + export default { register() {}, async bootstrap({ strapi }: { strapi: Core.Strapi }) { await grantPublicReadAccess(strapi); await disablePublicSignUp(strapi); + await ensureEnglishLocale(strapi); }, }; diff --git a/frontend/app/app.vue b/frontend/app/app.vue index ed9e94c..18056d2 100644 --- a/frontend/app/app.vue +++ b/frontend/app/app.vue @@ -1,3 +1,8 @@ + +