Written by: Geoffrey Callaghan
create a contact form with Docus
Create A Contact Form With Docus
To create a contact form in a Nuxt Content (Docus) site using FabForm, follow these steps. Docus is a documentation theme for Nuxt Content, and FabForm is a service for handling form submissions.
Set Up Nuxt Content (Docus) Project:
npx nuxi init my-docs
cd my-docs
npm install
npm install @nuxt/content-theme-docs
Configure Docus:
nuxt.config.ts
to use the Docus theme:
import { defineNuxtConfig } from 'nuxt'
export default defineNuxtConfig({
buildModules: [
'@nuxt/content-theme-docs'
],
content: {
liveEdit: false
}
})
Create a Contact Page:
contact.md
in your content
directory:
---
title: Contact Us
description: Get in touch with us
---
<form action="https://fabform.io/f/YOUR_FORM_ID" method="POST">
<div>
<label for="name">Name:</label><br>
<input type="text" id="name" name="name" required><br>
</div>
<div>
<label for="email">Email:</label><br>
<input type="email" id="email" name="email" required><br>
</div>
<div>
<label for="message">Message:</label><br>
<textarea id="message" name="message" required></textarea><br>
</div>
<div>
<input type="submit" value="Submit">
</div>
</form>
Configure FabForm:
Update Sidebar Navigation:
navigation
property in your Docus configuration to include the contact page. This configuration is usually found in content/config/navigation.json
or similar:
[
{
"title": "Home",
"to": "/"
},
{
"title": "Contact",
"to": "/contact"
}
]
Run Your Nuxt Content Site:
npm run dev
http://localhost:3000/contact
to ensure your contact form appears correctly and can submit data.Deploy Your Site:
npm run build
npm run generate
my-docs/
├── content/
│ ├── index.md
│ ├── contact.md
│ └── config/
│ └── navigation.json
├── nuxt.config.ts
├── package.json
nuxt.config.ts
:import { defineNuxtConfig } from 'nuxt'
export default defineNuxtConfig({
buildModules: [
'@nuxt/content-theme-docs'
],
content: {
liveEdit: false
}
})
contact.md
:---
title: Contact Us
description: Get in touch with us
---
<form action="https://fabform.io/f/YOUR_FORM_ID" method="POST">
<div>
<label for="name">Name:</label><br>
<input type="text" id="name" name="name" required><br>
</div>
<div>
<label for="email">Email:</label><br>
<input type="email" id="email" name="email" required><br>
</div>
<div>
<label for="message">Message:</label><br>
<textarea id="message" name="message" required></textarea><br>
</div>
<div>
<input type="submit" value="Submit">
</div>
</form>
navigation.json
:[
{
"title": "Home",
"to": "/"
},
{
"title": "Contact",
"to": "/contact"
}
]
By following these steps, you will have a fully functional contact form on your Nuxt Content (Docus) site that integrates with FabForm for handling submissions.