Skip to content

Commit

Permalink
Merge pull request #2687 from starknet-io/Blog-posts-latests-updates-…
Browse files Browse the repository at this point in the history
…side-banner

Blog post Latest Announcements side banner
  • Loading branch information
TalBenAvi authored Apr 4, 2024
2 parents f5619f0 + bcb99c1 commit 9d550d0
Show file tree
Hide file tree
Showing 27 changed files with 634 additions and 335 deletions.
10 changes: 10 additions & 0 deletions _data/settings/latest-announcements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- isActive: true
image: https://www.starknet.io/assets/final-.jpeg
text: What are onramps and cross rollup bridges?
buttonText: See more
buttonLink: /
- isActive: true
image: https://www.starknet.io/assets/guide-image-3-.jpg
text: What are onramps and cross rollup bridges?
buttonText: See more
buttonLink: /
19 changes: 19 additions & 0 deletions workspaces/cms-config/src/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,25 @@ export const topLevelBlocks = [
},
],
},
{
name: "side_sticky_banner",
label: "Side Sticky Banner",
widget: "object",
fields: [
{
name: "blocks",
label: "Blocks",
widget: "list",
types: [...blocks, flexLayout],
default: [],
},
{
name: "isActive",
widget: "boolean",
default: false,
},
],
},
flexLayout,
...blocks,
] satisfies CmsFieldList["types"];
2 changes: 1 addition & 1 deletion workspaces/cms-config/src/collections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ export const collections: CmsConfig["collections"] = [
SEOCollectionConfig,
roadmapPostsCollectionConfig,
roadmapVersionsCollectionConfig,
announcementsCollectionConfig
announcementsCollectionConfig,
];
98 changes: 69 additions & 29 deletions workspaces/cms-config/src/collections/settings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { linkFields } from "../blocks";
import { CmsCollection } from "../types";


const permissionOptions = [
{
label: "All",
Expand Down Expand Up @@ -43,7 +42,7 @@ const permissionOptions = [
label: "Roadmap and Announcements",
value: "roadmap",
},
]
];

export const settingsCollectionConfig = {
crowdin: true,
Expand All @@ -65,7 +64,7 @@ export const settingsCollectionConfig = {
label: "Title",
name: "title",
widget: "string",
crowdin: true
crowdin: true,
},
{
label: "Columns",
Expand All @@ -83,7 +82,7 @@ export const settingsCollectionConfig = {
name: "title",
required: false,
widget: "string",
crowdin: true
crowdin: true,
},
{
label: "Menu Items",
Expand Down Expand Up @@ -120,12 +119,12 @@ export const settingsCollectionConfig = {
{
name: "source",
widget: "string",
crowdin: false
crowdin: false,
},
{
name: "destination",
widget: "string",
crowdin: false
crowdin: false,
},
],
},
Expand All @@ -143,14 +142,14 @@ export const settingsCollectionConfig = {
widget: "list",
fields: [
{
name: 'category',
label: 'Category',
widget: 'relation',
collection: 'categories',
search_fields: ['name'],
value_field: 'id',
display_fields: ['name'],
options_length: 300
name: "category",
label: "Category",
widget: "relation",
collection: "categories",
search_fields: ["name"],
value_field: "id",
display_fields: ["name"],
options_length: 300,
},
],
},
Expand All @@ -171,7 +170,7 @@ export const settingsCollectionConfig = {
label: "Name",
name: "name",
widget: "string",
crowdin: true
crowdin: true,
},
{
label: "Type",
Expand Down Expand Up @@ -202,19 +201,19 @@ export const settingsCollectionConfig = {
label: "Twitter handle",
name: "twitter",
widget: "string",
crowdin: false
crowdin: false,
},
{
label: "Website url",
name: "website_url",
widget: "string",
crowdin: false
crowdin: false,
},
{
label: "Description",
name: "body",
widget: "string",
crowdin: true
crowdin: true,
},
],
},
Expand Down Expand Up @@ -255,7 +254,7 @@ export const settingsCollectionConfig = {
name: "title",
label: "Title",
widget: "string",
crowdin: true
crowdin: true,
},
{
name: "body",
Expand All @@ -268,7 +267,7 @@ export const settingsCollectionConfig = {
hint: "If page url is not specified (e.g. 'learn/glossary'), it will be used globally",
required: false,
widget: "string",
crowdin: false
crowdin: false,
},
],
},
Expand All @@ -294,7 +293,7 @@ export const settingsCollectionConfig = {
search_fields: ["title"],
value_field: "id",
display_fields: ["title"],
options_length: 300
options_length: 300,
},
],
},
Expand All @@ -315,36 +314,36 @@ export const settingsCollectionConfig = {
label: "Hero banner title",
widget: "string",
required: true,
crowdin: true
crowdin: true,
},
{
name: "hero_description",
label: "Hero description",
widget: "string",
required: true,
crowdin: true
crowdin: true,
},
{
name: "show_hero_cta",
label: "Show hero banner CTA",
widget: "boolean",
default: true,
crowdin: true
crowdin: true,
},
{
name: "hero_cta_copy",
label: "Hero banner CTA copy",
widget: "string",
required: false,
crowdin: true
crowdin: true,
},
{
name: "roadmap_post_ps",
label: "Roadmap post p.s. copy",
widget: "markdown",
required: false,
crowdin: true
}
crowdin: true,
},
],
},
{
Expand All @@ -369,14 +368,55 @@ export const settingsCollectionConfig = {
label: "Name",
widget: "string",
crowdin: false,
required: false
required: false,
},
{
name: "access",
label: "Access to collections",
multiple: true,
widget: "select",
options: permissionOptions
options: permissionOptions,
},
],
},
],
},
{
label: "Latest Announcements",
name: "LatestAnnouncements",
file: `_data/settings/latest-announcements.yml`,
crowdin: false,
fields: [
{
label: "announcements",
name: "announcements",
widget: "list",
fields: [
{
name: "image",
widget: "image",
crowdin: false,
},
{
name: "text",
widget: "string",
crowdin: false,
},
{
name: "buttonText",
widget: "string",
crowdin: false,
},
{
name: "buttonLink",
widget: "string",
crowdin: false,
},
{
name: "isActive",
widget: "boolean",
default: true,
crowdin: false,
},
],
},
Expand Down
26 changes: 26 additions & 0 deletions workspaces/cms-data/src/settings/latest-announcements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { getJSON } from "@starknet-io/cms-utils/src/index";

export type LatestAnnouncements = {
readonly image: string;
readonly text: string;
readonly buttonText: string;
readonly buttonLink: string;
readonly isActive: boolean;
};

export async function getLatestAnnouncements(
context: EventContext<{}, any, Record<string, unknown>>
) {
try {
const latestAnnouncements = await getJSON(
"data/latest-announcements/latest-announcements",
context
);

return latestAnnouncements;
} catch (cause) {
throw new Error("getLatestAnnouncements failed!", {
cause,
});
}
}
Loading

0 comments on commit 9d550d0

Please sign in to comment.