2.0.2 • Published 4 years ago
vite-plugin-sheets v2.0.2
vite-plugin-sheets
Relaces %sheets.<sheet>.<slot>% with content.
Useful when using Google Sheets as CMS. Spreadsheet must be shared with the service account.
Check out the Sheets API to get started. You must have a Google Cloud Project with the "Sheets API" enabled.
| :warning: Warning |
|---|
| Only loads sheets data once per build, this is to save API calls. Therefore changes made to the sheets during development will not be displayed until restarting the dev server. |
Required Options
creds: Path to service account credentialsspreadsheetId: Defines what Spreadsheet ID to point to
Other Options
slotColumn: Defaults to0. Which column to look use as slots.contentColumn: Defaults to1. Same asslotColumnbut for the content.ignore: Defaults totrue. Weather or not to treat row1as a header column.
Sample Config
export default {
plugins: [
sheets({
creds: "creds.json",
spreadsheetId: process.env.SPREADSHEET_ID
})
]
}Sample Sheet Setup
"Home" Sheet
| Slot | Content |
|---|---|
| title | Awesome Title |
| content | Cool content |
"About" Sheet
| Slot | Content |
|---|---|
| title | About Us |
| something | Other stuff |
The header row gets ignored by default.
titlein the "Home" sheet would be mapped to%sheets.home.title%contentin the "Home" sheet would be mapped to%sheets.home.content%titlein the "About" sheet would be mapped to%sheets.about.title%somethingin the "About" sheet would be mapped to%sheets.about.something%