1#![forbid(unsafe_code)]
2#![doc = include_str!("../README.md")]
3
4#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
6pub enum NuxtVersionFamily {
7 Nuxt2,
8 Nuxt3,
9 Nuxt4,
10}
11
12impl NuxtVersionFamily {
13 #[must_use]
15 pub const fn as_str(self) -> &'static str {
16 match self {
17 Self::Nuxt2 => "nuxt2",
18 Self::Nuxt3 => "nuxt3",
19 Self::Nuxt4 => "nuxt4",
20 }
21 }
22}
23
24#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub enum NuxtDirectoryKind {
27 Pages,
28 Components,
29 Composables,
30 Layouts,
31 Middleware,
32 Plugins,
33 Server,
34 Content,
35 Assets,
36 Public,
37}
38
39impl NuxtDirectoryKind {
40 #[must_use]
42 pub const fn as_str(self) -> &'static str {
43 match self {
44 Self::Pages => "pages",
45 Self::Components => "components",
46 Self::Composables => "composables",
47 Self::Layouts => "layouts",
48 Self::Middleware => "middleware",
49 Self::Plugins => "plugins",
50 Self::Server => "server",
51 Self::Content => "content",
52 Self::Assets => "assets",
53 Self::Public => "public",
54 }
55 }
56}
57
58#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
60pub enum NuxtRenderingMode {
61 Ssr,
62 Spa,
63 Static,
64 Hybrid,
65}
66
67impl NuxtRenderingMode {
68 #[must_use]
70 pub const fn as_str(self) -> &'static str {
71 match self {
72 Self::Ssr => "ssr",
73 Self::Spa => "spa",
74 Self::Static => "static",
75 Self::Hybrid => "hybrid",
76 }
77 }
78}
79
80#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
82pub enum NuxtConfigFile {
83 JavaScript,
84 TypeScript,
85 Mjs,
86 Mts,
87}
88
89impl NuxtConfigFile {
90 #[must_use]
92 pub const fn as_str(self) -> &'static str {
93 match self {
94 Self::JavaScript => "nuxt.config.js",
95 Self::TypeScript => "nuxt.config.ts",
96 Self::Mjs => "nuxt.config.mjs",
97 Self::Mts => "nuxt.config.mts",
98 }
99 }
100}
101
102#[cfg(test)]
103mod tests {
104 use super::{NuxtConfigFile, NuxtDirectoryKind, NuxtRenderingMode, NuxtVersionFamily};
105
106 #[test]
107 fn exposes_nuxt_labels() {
108 assert_eq!(NuxtVersionFamily::Nuxt3.as_str(), "nuxt3");
109 assert_eq!(NuxtDirectoryKind::Composables.as_str(), "composables");
110 assert_eq!(NuxtRenderingMode::Ssr.as_str(), "ssr");
111 assert_eq!(NuxtConfigFile::TypeScript.as_str(), "nuxt.config.ts");
112 }
113}