Skip to content

Commit c756cce

Browse files
authored
Merge pull request #30 from strapi/feat/2043-meilisearch
Feat: 2043 Meilisearch
2 parents f5d38a6 + 79efa2b commit c756cce

32 files changed

Lines changed: 1419 additions & 483 deletions

‎apps/strapi/.env.example‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,15 @@ STRAPI_PREVIEW_SECRET=your-secret-key
6969
# Shared secret with the Next.js app for triggering on-demand revalidation.
7070
# Must match `STRAPI_REVALIDATE_SECRET` in apps/ui/.env.local.
7171
STRAPI_REVALIDATE_SECRET=your-revalidate-secret
72+
73+
# ------- Meilisearch -------
74+
75+
# Meilisearch host URL
76+
MEILISEARCH_HOST=
77+
78+
# Master/admin API key used by the Strapi plugin to write indexes.
79+
MEILISEARCH_API_KEY=
80+
81+
# DANGER: Should be false while developing, to not populate production with test data.
82+
# DANGER: If you are not sure always leave false
83+
MEILISEARCH_PRODUCTION=false

‎apps/strapi/config/plugins.ts‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,54 @@ export default ({ env }) => {
6363
},
6464
},
6565

66+
meilisearch: {
67+
config: {
68+
host: env("MEILISEARCH_HOST", "http://localhost:7700"),
69+
apiKey: env("MEILISEARCH_API_KEY"),
70+
"case-study": {
71+
indexName: env.bool("MEILISEARCH_PRODUCTION", false)
72+
? "case-studies-production"
73+
: "case-studies-testing",
74+
entriesQuery: {
75+
populate: {
76+
coverImage: {
77+
populate: { image: { populate: { media: true } } },
78+
},
79+
categories: { fields: ["name", "slug"] },
80+
},
81+
},
82+
settings: {
83+
filterableAttributes: ["categories.slug"],
84+
searchableAttributes: ["title", "companyName", "description"],
85+
sortableAttributes: ["originalPublishedAt"],
86+
},
87+
},
88+
page: {
89+
indexName: env.bool("MEILISEARCH_PRODUCTION", false)
90+
? "pages-production"
91+
: "pages-testing",
92+
transformEntry({ entry }) {
93+
return {
94+
...entry,
95+
pageType:
96+
typeof entry.fullPath === "string" &&
97+
entry.fullPath.startsWith("/features")
98+
? "feature"
99+
: "page",
100+
}
101+
},
102+
settings: {
103+
filterableAttributes: ["pageType", "locale"],
104+
},
105+
},
106+
"blog-post": {
107+
indexName: env.bool("MEILISEARCH_PRODUCTION", false)
108+
? "blog-posts-production"
109+
: "blog-posts-testing",
110+
},
111+
},
112+
},
113+
66114
// Must be last — registers after custom field plugins (color-picker) to avoid #119
67115
// https://github.com/strapi-community/plugin-rest-cache/issues/119
68116
"rest-cache": {

‎apps/strapi/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"react-dom": "^18.0.0",
5050
"react-router-dom": "^6.0.0",
5151
"strapi-plugin-config-sync": "2.1.0",
52+
"strapi-plugin-meilisearch": "^0.16.2",
5253
"styled-components": "^6.0.0",
5354
"vitest": "catalog:",
5455
"zod": "^4.3.6"

‎apps/strapi/src/api/page/content-types/page/schema.json‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@
9292
"sections.community-banner",
9393
"sections.comparator-grid",
9494
"sections.disclaimer",
95-
"sections.richtext"
95+
"sections.richtext",
96+
"sections.dynamic-case-studies-grid",
97+
"sections.dynamic-features-grid"
9698
]
9799
},
98100
"children": {
@@ -109,12 +111,12 @@
109111
},
110112
"minimalLayout": {
111113
"type": "boolean",
112-
"default": false,
113114
"pluginOptions": {
114115
"i18n": {
115116
"localized": false
116117
}
117-
}
118+
},
119+
"default": false
118120
},
119121
"seo": {
120122
"type": "component",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"collectionName": "components_sections_dynamic_case_studies_grids",
3+
"info": {
4+
"displayName": "DynamicCaseStudiesGrid"
5+
},
6+
"options": {},
7+
"attributes": {
8+
"isHidden": {
9+
"type": "boolean",
10+
"default": false
11+
}
12+
},
13+
"config": {}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"collectionName": "components_sections_dynamic_features_grids",
3+
"info": {
4+
"displayName": "DynamicFeaturesGrid"
5+
},
6+
"options": {},
7+
"attributes": {
8+
"isHidden": {
9+
"type": "boolean",
10+
"default": false
11+
}
12+
},
13+
"config": {}
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default true

‎apps/strapi/types/generated/components.d.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,26 @@ export interface SectionsDisclaimer extends Struct.ComponentSchema {
10091009
}
10101010
}
10111011

1012+
export interface SectionsDynamicCaseStudiesGrid extends Struct.ComponentSchema {
1013+
collectionName: "components_sections_dynamic_case_studies_grids"
1014+
info: {
1015+
displayName: "DynamicCaseStudiesGrid"
1016+
}
1017+
attributes: {
1018+
isHidden: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo<false>
1019+
}
1020+
}
1021+
1022+
export interface SectionsDynamicFeaturesGrid extends Struct.ComponentSchema {
1023+
collectionName: "components_sections_dynamic_features_grids"
1024+
info: {
1025+
displayName: "DynamicFeaturesGrid"
1026+
}
1027+
attributes: {
1028+
isHidden: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo<false>
1029+
}
1030+
}
1031+
10121032
export interface SectionsFaqSection extends Struct.ComponentSchema {
10131033
collectionName: "components_sections_faq_section"
10141034
info: {
@@ -1557,6 +1577,8 @@ declare module "@strapi/strapi" {
15571577
"sections.comparator-grid": SectionsComparatorGrid
15581578
"sections.cta-banner": SectionsCtaBanner
15591579
"sections.disclaimer": SectionsDisclaimer
1580+
"sections.dynamic-case-studies-grid": SectionsDynamicCaseStudiesGrid
1581+
"sections.dynamic-features-grid": SectionsDynamicFeaturesGrid
15601582
"sections.faq-section": SectionsFaqSection
15611583
"sections.feature-card-grid": SectionsFeatureCardGrid
15621584
"sections.hero": SectionsHero

‎apps/strapi/types/generated/contentTypes.d.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,8 @@ export interface ApiPagePage extends Struct.CollectionTypeSchema {
12711271
"sections.comparator-grid",
12721272
"sections.disclaimer",
12731273
"sections.richtext",
1274+
"sections.dynamic-case-studies-grid",
1275+
"sections.dynamic-features-grid",
12741276
]
12751277
> &
12761278
Schema.Attribute.SetPluginOptions<{

0 commit comments

Comments
 (0)