|
1 | 1 | use std::path::PathBuf; |
2 | 2 |
|
3 | | -use chrono::NaiveDateTime; |
| 3 | +use chrono::{DateTime, NaiveDate, NaiveDateTime, Utc}; |
4 | 4 | use rari_data::baseline::SupportStatusWithByKey; |
5 | 5 | use rari_types::locale::{Locale, Native}; |
6 | 6 | use serde::{Deserialize, Serialize}; |
7 | 7 |
|
8 | 8 | use super::types::contributors::Usernames; |
9 | 9 | use super::types::curriculum::{CurriculumIndexEntry, CurriculumSidebarEntry, Template, Topic}; |
10 | 10 | use crate::pages::types::blog::BlogMeta; |
11 | | -use crate::pages::types::spa::BlogIndex; |
12 | 11 | use crate::specs::Specification; |
13 | 12 | use crate::utils::modified_dt; |
14 | 13 |
|
@@ -117,6 +116,11 @@ pub struct JsonDoc { |
117 | 116 | pub browser_compat: Vec<String>, |
118 | 117 | } |
119 | 118 |
|
| 119 | +#[derive(Debug, Clone, Serialize)] |
| 120 | +pub struct BlogIndex { |
| 121 | + pub posts: Vec<BlogMeta>, |
| 122 | +} |
| 123 | + |
120 | 124 | #[derive(Debug, Clone, Serialize)] |
121 | 125 | #[serde(untagged)] |
122 | 126 | pub enum HyData { |
@@ -246,6 +250,7 @@ pub enum BuiltDocy { |
246 | 250 | ContributorSpotlight(Box<JsonContributorSpotlight>), |
247 | 251 | BasicSPA(Box<JsonBasicSPA>), |
248 | 252 | GenericPage(Box<JsonGenericPage>), |
| 253 | + HomePageSPA(Box<JsonHomePageSPA>), |
249 | 254 | } |
250 | 255 |
|
251 | 256 | #[derive(Deserialize, Serialize, Clone, Debug, Default)] |
@@ -285,12 +290,72 @@ pub struct UrlNTitle { |
285 | 290 | pub struct JsonBasicSPA { |
286 | 291 | pub slug: &'static str, |
287 | 292 | pub page_title: &'static str, |
288 | | - pub page_description: &'static str, |
| 293 | + pub page_description: Option<&'static str>, |
289 | 294 | pub only_follow: bool, |
290 | 295 | pub no_indexing: bool, |
291 | 296 | pub url: String, |
292 | 297 | } |
293 | 298 |
|
| 299 | +#[derive(Debug, Clone, Serialize)] |
| 300 | +#[serde(rename_all = "camelCase")] |
| 301 | +pub struct HomePageFeaturedArticle { |
| 302 | + pub mdn_url: String, |
| 303 | + pub summay: String, |
| 304 | + pub title: String, |
| 305 | + pub tag: Option<Parent>, |
| 306 | +} |
| 307 | + |
| 308 | +#[derive(Debug, Clone, Serialize)] |
| 309 | +#[serde(rename_all = "camelCase")] |
| 310 | +pub struct HomePageFeaturedContributor { |
| 311 | + pub contributor_name: String, |
| 312 | + pub url: String, |
| 313 | + pub quote: String, |
| 314 | +} |
| 315 | + |
| 316 | +#[derive(Debug, Clone, Serialize)] |
| 317 | +pub struct NameUrl { |
| 318 | + pub name: String, |
| 319 | + pub url: String, |
| 320 | +} |
| 321 | + |
| 322 | +#[derive(Debug, Clone, Serialize)] |
| 323 | +pub struct HomePageLatestNewsItem { |
| 324 | + pub url: String, |
| 325 | + pub title: String, |
| 326 | + pub author: Option<String>, |
| 327 | + pub source: NameUrl, |
| 328 | + pub published_at: NaiveDate, |
| 329 | +} |
| 330 | + |
| 331 | +#[derive(Debug, Clone, Serialize)] |
| 332 | +pub struct HomePageRecentContribution { |
| 333 | + pub number: i64, |
| 334 | + pub title: String, |
| 335 | + pub updated_at: DateTime<Utc>, |
| 336 | + pub url: String, |
| 337 | + pub repo: NameUrl, |
| 338 | +} |
| 339 | + |
| 340 | +#[derive(Debug, Clone, Serialize)] |
| 341 | +pub struct ItemContainer<T> |
| 342 | +where |
| 343 | + T: Clone + Serialize, |
| 344 | +{ |
| 345 | + pub items: Vec<T>, |
| 346 | +} |
| 347 | +#[derive(Debug, Clone, Serialize)] |
| 348 | +#[serde(rename_all = "camelCase")] |
| 349 | +pub struct JsonHomePageSPA { |
| 350 | + pub slug: &'static str, |
| 351 | + pub page_title: &'static str, |
| 352 | + pub page_description: Option<&'static str>, |
| 353 | + pub featured_articles: Vec<HomePageFeaturedArticle>, |
| 354 | + pub featured_contributor: Option<HomePageFeaturedContributor>, |
| 355 | + pub latest_news: ItemContainer<HomePageLatestNewsItem>, |
| 356 | + pub recent_contributions: ItemContainer<HomePageRecentContribution>, |
| 357 | +} |
| 358 | + |
294 | 359 | #[derive(Debug, Clone, Serialize)] |
295 | 360 | #[serde(rename_all = "camelCase")] |
296 | 361 | pub struct JsonGenericHyData { |
|
0 commit comments