Skip to main content

leptos_next_metadata/conventions/
types.rs

1//! File convention types for leptos-next-metadata
2//!
3//! This module contains the type definitions for file conventions,
4//! including favicon, icon, sitemap, and manifest file structures.
5
6use std::path::PathBuf;
7
8/// Detected file conventions
9#[derive(Debug, Clone)]
10pub struct FileConventions {
11    /// Favicon files
12    pub favicon: Option<Vec<FaviconFile>>,
13
14    /// Icon files
15    pub icons: Option<Vec<IconFile>>,
16
17    /// Apple touch icons
18    pub apple_touch_icons: Option<Vec<AppleTouchIcon>>,
19
20    /// Robots.txt file
21    pub robots_txt: Option<RobotsTxt>,
22
23    /// Sitemap files
24    pub sitemaps: Option<Vec<SitemapFile>>,
25
26    /// Manifest files
27    pub manifests: Option<Vec<ManifestFile>>,
28
29    /// Open Graph image files
30    pub og_images: Option<Vec<OgImageFile>>,
31
32    /// Twitter image files
33    pub twitter_images: Option<Vec<TwitterImageFile>>,
34}
35
36/// Favicon file information
37#[derive(Debug, Clone)]
38pub struct FaviconFile {
39    /// File path
40    pub path: PathBuf,
41
42    /// File size in bytes
43    pub size: u64,
44
45    /// MIME type
46    pub mime_type: String,
47
48    /// Dimensions (if image)
49    pub dimensions: Option<(u32, u32)>,
50}
51
52/// Icon file information
53#[derive(Debug, Clone)]
54pub struct IconFile {
55    /// File path
56    pub path: PathBuf,
57
58    /// File size in bytes
59    pub size: u64,
60
61    /// MIME type
62    pub mime_type: String,
63
64    /// Dimensions
65    pub dimensions: Option<(u32, u32)>,
66
67    /// Icon type (e.g., "icon", "mask-icon")
68    pub icon_type: IconType,
69}
70
71/// Apple touch icon information
72#[derive(Debug, Clone)]
73pub struct AppleTouchIcon {
74    /// File path
75    pub path: PathBuf,
76
77    /// File size in bytes
78    pub size: u64,
79
80    /// MIME type
81    pub mime_type: String,
82
83    /// Dimensions
84    pub dimensions: Option<(u32, u32)>,
85
86    /// Color (if specified in filename)
87    pub color: Option<String>,
88}
89
90/// Robots.txt file information
91#[derive(Debug, Clone)]
92pub struct RobotsTxt {
93    /// File path
94    pub path: PathBuf,
95
96    /// File size in bytes
97    pub size: u64,
98
99    /// Content (first few lines for preview)
100    pub preview: String,
101}
102
103/// Sitemap file information
104#[derive(Debug, Clone)]
105pub struct SitemapFile {
106    /// File path
107    pub path: PathBuf,
108
109    /// File size in bytes
110    pub size: u64,
111
112    /// MIME type
113    pub mime_type: String,
114
115    /// Sitemap type
116    pub sitemap_type: SitemapType,
117}
118
119/// Manifest file information
120#[derive(Debug, Clone)]
121pub struct ManifestFile {
122    /// File path
123    pub path: PathBuf,
124
125    /// File size in bytes
126    pub size: u64,
127
128    /// MIME type
129    pub mime_type: String,
130
131    /// Manifest type
132    pub manifest_type: ManifestType,
133}
134
135/// Open Graph image file information
136#[derive(Debug, Clone)]
137pub struct OgImageFile {
138    /// File path
139    pub path: PathBuf,
140
141    /// File size in bytes
142    pub size: u64,
143
144    /// MIME type
145    pub mime_type: String,
146
147    /// Dimensions
148    pub dimensions: Option<(u32, u32)>,
149
150    /// Route pattern this image applies to
151    pub route_pattern: Option<String>,
152}
153
154/// Twitter image file information
155#[derive(Debug, Clone)]
156pub struct TwitterImageFile {
157    /// File path
158    pub path: PathBuf,
159
160    /// File size in bytes
161    pub size: u64,
162
163    /// MIME type
164    pub mime_type: String,
165
166    /// Dimensions
167    pub dimensions: Option<(u32, u32)>,
168
169    /// Route pattern this image applies to
170    pub route_pattern: Option<String>,
171}
172
173/// Icon types
174#[derive(Debug, Clone, PartialEq, Eq)]
175pub enum IconType {
176    /// Standard icon
177    Icon,
178
179    /// Mask icon (SVG)
180    MaskIcon,
181
182    /// Shortcut icon
183    ShortcutIcon,
184}
185
186/// Sitemap types
187#[derive(Debug, Clone, PartialEq, Eq)]
188pub enum SitemapType {
189    /// Standard sitemap
190    Sitemap,
191
192    /// Sitemap index
193    SitemapIndex,
194
195    /// Robots.txt sitemap
196    RobotsSitemap,
197}
198
199/// Manifest types
200#[derive(Debug, Clone, PartialEq, Eq)]
201pub enum ManifestType {
202    /// Web app manifest
203    WebAppManifest,
204    /// PWA manifest
205    PWAManifest,
206}
207
208/// File metadata
209#[derive(Debug, Clone)]
210pub struct FileMetadata {
211    /// File size in bytes
212    pub size: u64,
213
214    /// MIME type
215    pub mime_type: String,
216
217    /// Dimensions (for images)
218    pub dimensions: Option<(u32, u32)>,
219}