1.3 KiB
1.3 KiB
Setup
- We always use Nuxt together with Tailwind. Install tailwind like that: https://tailwindcss.com/docs/installation/framework-guides/nuxt
Components
- Ausnahmslos template -> script -> style von oben nach unten
- Immer
<script setup lang="ts"></script> und <style scoped></style>
General Code Best Practices:
- Keine ternären Operatoren, Immer switch oder if
- Null-Checks so früh wie möglich. Vermeiden von ! oder ?
- Nutz shared/useHttp für Requests.
- Nutz
import format from "@stdlib/string-format";
Types und API Calls
- Types und Api Calls werden wie folgt unterteilt. Immer ein Type und ein API Objekt wie
export interface Project {
name: string
}
export class ProjectAPI {
static get() {
return usePost<Project>("/api/projects");
}
}
- Verwendung im Komponente:
<script setup lang="ts">
const {...} state = ProjectAPI.get();
onMounted(() => {
state.execute();
})
</script>
Pages und Components
- Seiten beinhalten minimal Inhalt. Der Hauptteil des Inhalts ist in components. Dort werden auch Types/Klassen/Interfaces/Requests angelegt. Wir arbeiten feature-first, also packen alle inhaltlich zusammengehörigen Code in einen Bereich also components/projects oder components/images