added seeder for legacy apge and added the legacy page

This commit is contained in:
teledrisi
2026-10-05 17:32:06 +02:00
parent a5c531be00
commit 98fae066bc
30 changed files with 1488 additions and 181 deletions
+189 -7
View File
@@ -1,9 +1,10 @@
/* ============================================================================
SEED - APPROVED CONTENT
----------------------------------------------------------------------------
Everything in this file is transcribed from docs/, in both languages, and
nothing in it is invented. That is the whole point of keeping it apart from
demo.ts: this content is safe to publish.
Everything in this file is transcribed from docs/ or the supplied project
content suggestions, in both languages, and nothing in it is invented. That
is the whole point of keeping it apart from demo.ts: this content is safe to
publish.
SOURCES
docs/SHARPER_Website_Draft_Section_EN_AR.docx sections 1-9, EN and AR
@@ -13,6 +14,9 @@
docs/SHARPER Home Page .docx the launch article, EN/AR
docs/UEC_SHARPER_Website_TOR V3.docx the consortium and the
project's purpose
SHARP-ER Website Content suggestions submitted by Isam Saidi, supplied by
the project team: SHARP I/II
legacy text and historical figures
WHAT docs/ DOES NOT SUPPLY, AND IS THEREFORE NOT HERE
* Figures. Every number in the draft is bracketed and marked "TBD ... must
@@ -424,10 +428,6 @@ export const LAUNCH_ARTICLE = {
export const HOME_PAGE: Localised<SeedData> = {
en: {
hero: {
/* No `eyebrow`. The design draws a status pill reading "Now open -
Funding calls for Libyan organisations"; whether a call is open on any
given day is a fact about the project, not about the design, so the
pill stays unwritten until an editor writes it. */
headline: 'Advancing Justice and Accountability, Led by Libyan Communities',
subheading:
'SHARP-ER — Shared Action on Rule of Law Progress, Exit Route — works with civil society organisations, municipalities, and community leaders across Libya to strengthen access to justice, accountability, and local governance. Funded by the European Union, running to December 2027.',
@@ -547,6 +547,188 @@ export const ABOUT_PAGE: Localised<SeedData> = {
},
};
/**
* Facts and figures below come from "SHARP I Programme SUMMARY.docx" and
* "SHARP II Programme SUMMARY.docx". English page copy paraphrases the source;
* Arabic page copy translates it. UI headings are editorial labels, not quotes.
* The home Legacy section is stored here with the two programme records.
*/
export const LEGACY_PAGE: Localised<SeedData> = {
en: {
homeEyebrow: 'SHARP I and SHARP II',
homeHeading: 'Dialogue and local action in Libya, 2019–2024',
homeLead:
'Two EU-funded programmes supported rule of law dialogue, civil society capacity, and local action across Libya.',
hero: {
eyebrow: 'SHARP I and SHARP II',
headline: 'Dialogue and local action across Libya',
subheading:
'From November 2019 to August 2024, two EU-funded programmes supported rule of law dialogue, civil society capacity, and locally led action.',
},
stageOne: {
name: 'SHARP I',
years: 'November 2019 – August 2022',
summary:
'Built dialogue and local capacity through research, learning, and community-led action.',
description:
`The EU-funded SHARP I programme was implemented by Institute Clingendael and Bureau Ensemble with Libyan civil society organisations, local authorities, and national institutions. From November 2019 to August 2022, it worked to strengthen Libya’s rule of law through dialogue, research, and local action. Budget: €1.996 million.\n\n### Objectives\n- Strengthen Libyan institutions’ ability to respond to rule of law challenges.\n- Build the organisational capabilities of Libyan change agents.\n- Foster dialogue and information-sharing between stakeholders.\n\n### Dialogue and learning\nThe programme held 102 Search, Understand, and Question (SUQ) dialogues with 1,583 participants; 48% of participants were women. Topics included human rights, transitional justice, and local governance. A further 46 Training & Learning sessions covered facilitation, project management, and monitoring.\n\n### Community action\nTwenty-one sub-contract actions addressed conflict mediation, access to justice, women’s rights, labour rights, and civil-society and media engagement. They produced 62 workshops, 6 research papers, 24 training sessions, and 1,555 media outreach activities.\n\n### Results and lasting value\n87% of SUQ participants considered the discussions relevant, and 75% believed SHARP could contribute to rule of law change. Projects strengthened CSO reporting skills and partnerships with local authorities. Libyan-led initiatives built community trust; the programme adapted to pandemic and security constraints with virtual activities and local dialogue, helping CSOs develop lasting networks.\n\n### What followed\nThe EU approved SHARP II to build on these lessons: deepen dialogue, focus on four to six rule of law themes while retaining flexibility, strengthen CSO project design and evaluation, and support durable government–CSO networks.`,
metrics: [
{ value: '102', label: 'SUQ dialogues' },
{ value: '1,583', label: 'Dialogue participants' },
{ value: '48%', label: 'Women participants' },
{ value: '46', label: 'Learning sessions' },
{ value: '21', label: 'Sub-contract actions' },
{ value: '62', label: 'Workshops delivered' },
{ value: '6', label: 'Research papers' },
{ value: '24', label: 'Training sessions' },
{ value: '1,555', label: 'Media outreach activities' },
{ value: '87%', label: 'Found dialogues relevant' },
{ value: '75%', label: 'Saw potential for change' },
],
focusHeading: 'Areas of work',
focusAreas: [
{ name: 'Human rights' },
{ name: 'Transitional justice' },
{ name: 'Local governance' },
{ name: 'Conflict mediation' },
{ name: 'Access to justice' },
{ name: 'Women’s rights' },
{ name: 'Labour rights' },
{ name: 'Civil society and media' },
],
galleryHeading: 'SHARP I in the field',
},
stageTwo: {
name: 'SHARP II',
years: 'September 2022 – August 2024',
summary:
'Expanded a nationwide civil-society network and turned inclusive dialogue into community action.',
description:
`Funded by the European Union and implemented by Bureau Ensemble with Libyan partners, SHARP II built on SHARP I to strengthen the rule of law, stability, and participatory governance. From September 2022 to August 2024, the programme had a budget of €1.426 million.\n\n### Priorities\nSHARP II aimed to grow a national network of rule of law dialogue groups; build social cohesion and consensus locally, regionally, and nationally; organise inclusive dialogues on rule of law and positive citizenship; and support small community actions.\n\n### Dialogue and network\n157 SUQ dialogues engaged 2,554 participants, 44% of them women. Discussions covered access to justice, women’s empowerment, local governance, and the media’s role in the rule of law. The network grew to 64 active CSOs from 27, reaching every region, including marginalised areas in the south.\n\n### Skills and community action\nSix Training & Learning sessions covered facilitation, project management, and monitoring. Advanced training reached 100 participants, with 24 certified as trainers. All 34 approved sub-contracts were implemented, addressing legal awareness, reconciliation, women’s rights, gender-based violence, municipal capacity, ethical journalism, and misinformation. Activities reached 1,487 trainees and 1,697 workshop participants; awareness campaigns benefited 2,896 people.\n\n### Policy, communication, and impact\nRegional and national dialogues informed recommendations on faster court processes and legal aid, municipal empowerment under Local Governance Law 59, and media transparency and hate speech. Libyan-led monitoring supported adaptive delivery, while 1,555 media outreach activities amplified the work. CSOs led 100% of activities; ministries and municipalities partnered with them, and young people, displaced people, and persons with disabilities took part.\n\n### A sustainable exit\nThe March–August 2024 exit phase shaped three pillars for continued impact: Access to Justice (legal aid, mediation, and policy reform), TAZIZ (municipal capacity and citizen engagement), and ADWA (ethical journalism and countering misinformation). United Efforts was established and registered as a Libyan legal entity to help sustain the work.`,
metrics: [
{ value: '157', label: 'SUQ dialogues' },
{ value: '2,554', label: 'Dialogue participants' },
{ value: '64', label: 'Active CSOs' },
{ value: '44%', label: 'Women participants' },
{ value: '34', label: 'Sub-contracts' },
{ value: '100', label: 'Advanced training participants' },
{ value: '24', label: 'Certified trainers' },
{ value: '1,487', label: 'Trainees' },
{ value: '1,697', label: 'Workshop participants' },
{ value: '2,896', label: 'Awareness campaign beneficiaries' },
{ value: '1,555', label: 'Media outreach activities' },
],
focusHeading: 'Areas of work',
focusAreas: [
{ name: 'Access to justice' },
{ name: 'Women’s empowerment' },
{ name: 'Local governance' },
{ name: 'Media and rule of law' },
{ name: 'Social cohesion' },
{ name: 'Rule of law' },
{ name: 'Positive citizenship' },
],
galleryHeading: 'SHARP II in the field',
},
closingHeading: 'SHARP II’s exit phase',
closingBody: [
'From March to August 2024, the SHARP II exit phase focused on access to justice, local governance through TAZIZ, and media through ADWA.',
'United Efforts was established and registered as a Libyan legal entity. The SHARP II summary identifies a stable nationwide civil society network and a roadmap for future EU–Libya collaboration through SHARP-ER.',
].join('\n\n'),
seo: {
metaTitle: 'SHARP Legacy',
metaDescription:
'Discover the experience, achievements, and networks built through SHARP I and SHARP II in Libya.',
},
},
ar: {
homeEyebrow: 'شارب الأول وشارب الثاني',
homeHeading: 'الحوار والعمل المحلي في ليبيا، 2019–2024',
homeLead:
'دعم برنامجان ممولان من الاتحاد الأوروبي الحوار حول سيادة القانون، وقدرات المجتمع المدني، والعمل المحلي في مختلف أنحاء ليبيا.',
hero: {
eyebrow: 'شارب الأول وشارب الثاني',
headline: 'الحوار والعمل المحلي في مختلف أنحاء ليبيا',
subheading:
'من نوفمبر 2019 إلى أغسطس 2024، دعم برنامجان ممولان من الاتحاد الأوروبي الحوار حول سيادة القانون، وقدرات المجتمع المدني، والعمل بقيادة محلية.',
},
stageOne: {
name: 'شارب الأول',
years: 'نوفمبر 2019 – أغسطس 2022',
summary: 'عزّز الحوار والقدرات المحلية من خلال البحث والتعلّم والعمل المجتمعي.',
description:
`نفّذ معهد كلينغندايل ومؤسسة Bureau Ensemble برنامج شارب الأول بتمويل من الاتحاد الأوروبي، وبالتعاون مع منظمات المجتمع المدني والسلطات المحلية والمؤسسات الوطنية الليبية. عمل البرنامج من نوفمبر 2019 إلى أغسطس 2022 على دعم سيادة القانون في ليبيا عبر الحوار والبحث والعمل المحلي، بميزانية بلغت 1.996 مليون يورو.\n\n### الأهداف\n- تعزيز قدرة المؤسسات الليبية على الاستجابة لتحديات سيادة القانون.\n- بناء القدرات التنظيمية للفاعلين الليبيين الساعين إلى التغيير.\n- تشجيع الحوار وتبادل المعلومات بين أصحاب المصلحة.\n\n### الحوار والتعلّم\nعُقدت 102 جلسة «ابحث، افهم، واسأل» (SUQ)، بمشاركة 1,583 شخصاً، وكانت نسبة النساء 48%. وتناولت الجلسات حقوق الإنسان والعدالة الانتقالية والحوكمة المحلية. كما عُقدت 46 جلسة للتدريب والتعلّم حول التيسير وإدارة المشاريع والرصد.\n\n### العمل المجتمعي\nنُفّذ 21 مشروعاً فرعياً تناولت الوساطة في النزاعات والوصول إلى العدالة وحقوق النساء وحقوق العمال ومشاركة المجتمع المدني والإعلام. وأسفرت عن 62 ورشة عمل و6 أوراق بحثية و24 جلسة تدريبية و1,555 نشاطاً للتواصل الإعلامي.\n\n### النتائج والأثر المستدام\nرأى 87% من المشاركين أن جلسات الحوار ذات صلة، واعتقد 75% أن شارب قادر على الإسهام في تغيير واقع سيادة القانون. وعززت المشاريع مهارات إعداد التقارير لدى منظمات المجتمع المدني وشراكاتها مع السلطات المحلية. كما دعمت المبادرات بقيادة ليبية الثقة المجتمعية، وتكيّف البرنامج مع قيود الجائحة والأوضاع الأمنية عبر الأنشطة الافتراضية والحوار المحلي، بما ساعد المنظمات على بناء شبكات طويلة الأمد.\n\n### ما تلا ذلك\nوافق الاتحاد الأوروبي على شارب الثاني للاستفادة من هذه الخبرات: تعميق الحوار، والتركيز على أربعة إلى ستة موضوعات مع الحفاظ على المرونة، وتعزيز مهارات تصميم المشاريع وتقييمها لدى منظمات المجتمع المدني، ودعم شبكات مستدامة بين الحكومة والمجتمع المدني.`,
metrics: [
{ value: '102', label: 'جلسة حوار SUQ' },
{ value: '1,583', label: 'مشاركاً في جلسات الحوار' },
{ value: '48%', label: 'مشاركة النساء' },
{ value: '46', label: 'جلسة للتعلّم' },
{ value: '21', label: 'عملاً بعقد فرعي' },
{ value: '62', label: 'ورشة عمل' },
{ value: '6', label: 'أوراق بحثية' },
{ value: '24', label: 'جلسة تدريبية' },
{ value: '1,555', label: 'نشاطاً للتواصل الإعلامي' },
{ value: '87%', label: 'وجدوا الحوارات ذات صلة' },
{ value: '75%', label: 'رأوا إمكانية إحداث تغيير' },
],
focusHeading: 'مجالات العمل',
focusAreas: [
{ name: 'حقوق الإنسان' },
{ name: 'العدالة الانتقالية' },
{ name: 'الحوكمة المحلية' },
{ name: 'الوساطة في النزاعات' },
{ name: 'الوصول إلى العدالة' },
{ name: 'حقوق النساء' },
{ name: 'حقوق العمال' },
{ name: 'المجتمع المدني والإعلام' },
],
galleryHeading: 'شارب الأول ميدانياً',
},
stageTwo: {
name: 'شارب الثاني',
years: 'سبتمبر 2022 – أغسطس 2024',
summary:
'وسّع شبكة المجتمع المدني الوطنية وحوّل الحوار الشامل إلى عمل مجتمعي.',
description:
`بتمويل من الاتحاد الأوروبي وتنفيذ Bureau Ensemble بالشراكة مع فاعلين ليبيين، بنى شارب الثاني على إنجازات شارب الأول لتعزيز سيادة القانون والاستقرار والحوكمة التشاركية. امتد البرنامج من سبتمبر 2022 إلى أغسطس 2024 بميزانية 1.426 مليون يورو.\n\n### الأولويات\nعمل شارب الثاني على توسيع شبكة وطنية لمجموعات الحوار حول سيادة القانون، وتعزيز التماسك الاجتماعي والتوافق محلياً وإقليمياً ووطنياً، وتنظيم حوارات شاملة حول سيادة القانون والمواطنة الإيجابية، ودعم مبادرات مجتمعية صغيرة.\n\n### الحوار وتوسيع الشبكة\nعُقدت 157 جلسة حوار SUQ بمشاركة 2,554 شخصاً، وكانت نسبة النساء 44%. وتناولت الحوارات الوصول إلى العدالة وتمكين المرأة والحوكمة المحلية ودور الإعلام في سيادة القانون. ونمت الشبكة إلى 64 منظمة مجتمع مدني ناشطة بعد أن كانت 27، وامتدت إلى جميع المناطق بما فيها المناطق المهمشة في الجنوب.\n\n### بناء القدرات والعمل المجتمعي\nعُقدت 6 جلسات للتدريب والتعلّم حول التيسير وإدارة المشاريع والرصد. وشمل التدريب المتقدم 100 مشارك، حصل 24 منهم على اعتماد مدربين. ونُفّذت العقود الفرعية الـ34 المعتمدة، وتناولت التوعية القانونية والمصالحة وحقوق المرأة ومكافحة العنف القائم على النوع الاجتماعي وبناء قدرات البلديات والصحافة الأخلاقية ومواجهة المعلومات المضللة. ووصلت الأنشطة إلى 1,487 متدرباً و1,697 مشاركاً في الورش؛ واستفاد 2,896 شخصاً من حملات التوعية.\n\n### السياسات والتواصل والأثر\nأسهمت الحوارات الإقليمية والوطنية في صياغة توصيات لتسريع إجراءات المحاكم وتوفير مكاتب للمساعدة القانونية، وتمكين البلديات بموجب قانون الحكم المحلي رقم 59، ودعم الشفافية الإعلامية ومكافحة خطاب الكراهية. وأسهم الرصد بقيادة ليبية في تكييف التنفيذ، كما عززت 1,555 نشاطاً إعلامياً أثر البرنامج. وقادت منظمات المجتمع المدني 100% من الأنشطة، وتعاونت معها الوزارات والبلديات، وشارك الشباب والنازحون والأشخاص ذوو الإعاقة.\n\n### خطة خروج مستدامة\nصممت مرحلة الخروج، من مارس إلى أغسطس 2024، ثلاثة مشاريع لضمان الأثر على المدى الطويل: الوصول إلى العدالة عبر المساعدة القانونية والتدريب على الوساطة والإصلاحات؛ و«تعزيز» (TAZIZ) لبناء قدرات البلديات ومشاركة المواطنين؛ و«أضواء» (ADWA) للصحافة الأخلاقية ومواجهة المعلومات المضللة. كما أُسست وسُجلت «United Efforts» ككيان قانوني ليبي لضمان استمرارية العمل.`,
metrics: [
{ value: '157', label: 'جلسة حوار SUQ' },
{ value: '2,554', label: 'مشاركاً في الحوار' },
{ value: '64', label: 'منظمة مجتمع مدني ناشطة' },
{ value: '44%', label: 'مشاركة النساء' },
{ value: '34', label: 'عقداً فرعياً' },
{ value: '100', label: 'مشاركاً في التدريب المتقدم' },
{ value: '24', label: 'مدرباً معتمداً' },
{ value: '1,487', label: 'متدرباً' },
{ value: '1,697', label: 'مشاركاً في الورش' },
{ value: '2,896', label: 'مستفيداً من حملات التوعية' },
{ value: '1,555', label: 'نشاطاً للتواصل الإعلامي' },
],
focusHeading: 'مجالات العمل',
focusAreas: [
{ name: 'الوصول إلى العدالة' },
{ name: 'تمكين المرأة' },
{ name: 'الحوكمة المحلية' },
{ name: 'الإعلام وسيادة القانون' },
{ name: 'التماسك الاجتماعي' },
{ name: 'سيادة القانون' },
{ name: 'المواطنة الإيجابية' },
],
galleryHeading: 'شارب الثاني ميدانياً',
},
closingHeading: 'مرحلة خروج شارب الثاني',
closingBody: [
'من مارس إلى أغسطس 2024، ركزت مرحلة خروج شارب الثاني على الوصول إلى العدالة، والحوكمة المحلية عبر «تعزيز» (TAZIZ)، والإعلام عبر «أضواء» (ADWA).',
'أُسست «United Efforts» وسُجلت ككيان قانوني ليبي. ويشير ملخص شارب الثاني إلى شبكة وطنية مستقرة من منظمات المجتمع المدني وخارطة طريق لتعاون الاتحاد الأوروبي وليبيا مستقبلاً عبر شارب-إي آر.',
].join('\n\n'),
seo: {
metaTitle: 'إرث شارب',
metaDescription:
'اكتشفوا الخبرات والإنجازات والشبكات التي بُنيت من خلال مشروعي شارب الأول والثاني في ليبيا.',
},
},
};
/** The role chip and its line on the About page's consortium cards. */
export const CONSORTIUM_ROLES: Readonly<
Record<string, Localised<{ role: string; roleDescription: string }>>
-12
View File
@@ -911,15 +911,3 @@ export const demoKnowledge = (now: Date): readonly DemoEntry[] => {
),
];
};
/**
* The home page fields the demo set overrides.
*
* The status pill is the one piece of approved-looking copy the demo writes,
* and it is true of the demo data: `demo-call-for-expression-of-interest-
* round-two` really is open on a demo-seeded site.
*/
export const DEMO_HOME_PAGE: Localised<SeedData> = {
en: { hero: { eyebrow: 'Now open · Funding calls for Libyan organisations' } },
ar: { hero: { eyebrow: 'مفتوح الآن · دعوات تمويل للمنظمات الليبية' } },
};
+74 -12
View File
@@ -4,6 +4,7 @@
Run it with `pnpm seed` from the repository root, or from apps/cms:
pnpm seed the approved content only (approved.ts)
pnpm seed -- --legacy-only only create/update the Legacy single type
pnpm seed --demo the same, plus the invented fixtures (demo.ts)
pnpm seed --demo --clean remove the invented fixtures, leave the rest
@@ -17,10 +18,9 @@
documentId, and a relation can only be set once its target exists.
WHAT IT DOES NOT TOUCH
* Media. The seed uploads nothing. Where a page already has a picture -
the home hero, most of all - the existing file is read back and written
out again with the new copy, because a component is replaced wholesale
on write and anything left out of the payload is gone.
* Media. The seed uploads nothing. Existing home and Legacy hero/gallery
media are read back and written out again with the copy, because a
component is replaced wholesale on write and omitted media is removed.
* Submissions. `application`, `event-registration` and `contact-submission`
hold personal data. Nothing writes to them here, not even in demo mode.
* Locales and permissions. Those are reconciled at boot by src/bootstrap.
@@ -35,6 +35,7 @@ import {
CONSORTIUM_ROLES,
CONTACT_PAGE,
HOME_PAGE,
LEGACY_PAGE,
LAUNCH_ARTICLE,
SITE_SETTINGS,
TOPICS,
@@ -43,7 +44,6 @@ import {
} from './approved';
import {
DEMO_FAQS,
DEMO_HOME_PAGE,
DEMO_PARTNERS,
DEMO_PARTNER_SLUGS,
DEMO_PREFIX,
@@ -59,6 +59,7 @@ import {
deleteBySlugPrefix,
deleteWhere,
mediaId,
mediaIds,
readExisting,
upsert,
type Localised,
@@ -71,12 +72,15 @@ export interface SeedOptions {
readonly demo: boolean;
/** With `demo`, remove those fixtures instead of writing them. */
readonly clean: boolean;
/** Write only the bilingual Legacy single type, preserving its media. */
readonly legacyOnly: boolean;
}
const UID = {
siteSettings: 'api::site-settings.site-settings',
homePage: 'api::home-page.home-page',
aboutPage: 'api::about-page.about-page',
legacyPage: 'api::legacy-page.legacy-page',
whatWeDoPage: 'api::what-we-do-page.what-we-do-page',
contactPage: 'api::contact-page.contact-page',
partner: 'api::partner.partner',
@@ -218,6 +222,8 @@ async function seedApproved(strapi: Core.Strapi): Promise<{
});
log(strapi, 'about page');
await seedLegacyPage(strapi);
await upsert(strapi, UID.whatWeDoPage, WHAT_WE_DO_PAGE);
log(strapi, 'what we do page');
@@ -227,6 +233,57 @@ async function seedApproved(strapi: Core.Strapi): Promise<{
return { partners, topics, launchArticleId: launch.documentId };
}
/** Seed only the Legacy single type, leaving every other CMS record untouched. */
async function seedLegacyPage(strapi: Core.Strapi): Promise<void> {
/* A component is replaced wholesale on update. Carry editor-selected hero
and phase-gallery media across reseeds so the approved copy never drops it. */
const populate = [
'hero.media',
'stageOne.images',
'stageTwo.images',
];
const existingArabic = await readExisting(strapi, UID.legacyPage, populate);
const existingEnglish = await readExisting(strapi, UID.legacyPage, populate, undefined, 'en');
const existingFor = (locale: 'en' | 'ar') =>
locale === 'en' ? existingEnglish ?? existingArabic : existingArabic ?? existingEnglish;
const mediaFor = (locale: 'en' | 'ar') => {
const existing = existingFor(locale);
return {
hero: mediaId(existing?.hero, 'media'),
one: mediaIds(existing?.stageOne, 'images'),
two: mediaIds(existing?.stageTwo, 'images'),
};
};
const enMedia = mediaFor('en');
const arMedia = mediaFor('ar');
const withGallery = (stage: unknown, images: number[]): SeedData => ({
...(stage as SeedData),
...(images.length > 0 ? { images } : {}),
});
await upsert(strapi, UID.legacyPage, {
en: {
...LEGACY_PAGE.en,
hero: {
...(LEGACY_PAGE.en.hero as SeedData),
...(enMedia.hero ? { media: enMedia.hero } : {}),
},
stageOne: withGallery(LEGACY_PAGE.en.stageOne, enMedia.one),
stageTwo: withGallery(LEGACY_PAGE.en.stageTwo, enMedia.two),
},
ar: {
...LEGACY_PAGE.ar,
hero: {
...(LEGACY_PAGE.ar.hero as SeedData),
...(arMedia.hero ? { media: arMedia.hero } : {}),
},
stageOne: withGallery(LEGACY_PAGE.ar.stageOne, arMedia.one),
stageTwo: withGallery(LEGACY_PAGE.ar.stageTwo, arMedia.two),
},
});
log(strapi, 'legacy page');
}
/* ---------------------------------------------------------------------------
THE DEMO SET
------------------------------------------------------------------------ */
@@ -326,11 +383,10 @@ async function seedDemo(
}
log(strapi, `${knowledge.length} demo knowledge items`);
/* Finally the home page, which the demo set only adds to: the status pill,
the network logo wall (twelve organisations, which is what turns the wall
into the design's marquee), and two network stories beside the real launch
article. The hero is rewritten in full, media included, because writing a
component replaces it. */
/* Finally the home page: the demo set adds twelve organisations to the
network logo wall and two network stories beside the real launch article.
The hero is rewritten in full, media included, because writing a component
replaces it. */
const existingHome = await readExisting(strapi, UID.homePage, ['hero.media']);
const heroMedia = mediaId(existingHome?.hero, 'media');
@@ -344,7 +400,6 @@ async function seedDemo(
...HOME_PAGE[locale],
hero: {
...(HOME_PAGE[locale].hero as SeedData),
...(DEMO_HOME_PAGE[locale].hero as SeedData),
...(heroMedia ? { media: heroMedia } : {}),
},
featuredNews: featured,
@@ -376,7 +431,7 @@ async function cleanDemo(strapi: Core.Strapi): Promise<void> {
/* The home page is approved content with demo fields written onto it, so it
is put back rather than deleted. Deleting the partners above already
emptied the wall; this takes the status pill off again. */
emptied the wall. */
const existingHome = await readExisting(strapi, UID.homePage, ['hero.media']);
const heroMedia = mediaId(existingHome?.hero, 'media');
@@ -420,6 +475,12 @@ export async function runSeed(strapi: Core.Strapi, options: SeedOptions): Promis
return;
}
if (options.legacyOnly) {
if (options.demo) throw new Error('[seed] --legacy-only cannot be combined with --demo.');
await seedLegacyPage(strapi);
return;
}
const context = await seedApproved(strapi);
if (options.demo) {
@@ -435,6 +496,7 @@ export function parseSeedOptions(argv: readonly string[]): SeedOptions {
return {
demo: argv.includes('--demo'),
clean: argv.includes('--clean'),
legacyOnly: argv.includes('--legacy-only'),
};
}
+15 -2
View File
@@ -218,11 +218,12 @@ export async function readExisting(
strapi: Core.Strapi,
uid: SeedUid,
populate: string[],
find?: SeedData
find?: SeedData,
locale: SeedLocale = 'ar'
): Promise<SeedDocument | null> {
return documents(strapi, uid).findFirst({
...(find ? { filters: find } : {}),
locale: 'ar',
locale,
...draftFilter(strapi, uid),
populate,
});
@@ -236,3 +237,15 @@ export function mediaId(component: unknown, field: string): number | undefined {
const id = (media as Record<string, unknown>).id;
return typeof id === 'number' ? id : undefined;
}
/** The ids of populated media entries nested in a component. */
export function mediaIds(component: unknown, field: string): number[] {
if (!component || typeof component !== 'object') return [];
const media = (component as Record<string, unknown>)[field];
if (!Array.isArray(media)) return [];
return media.flatMap((item: unknown) => {
if (!item || typeof item !== 'object') return [];
const id = (item as Record<string, unknown>).id;
return typeof id === 'number' ? [id] : [];
});
}