Skip to content

Instantly share code, notes, and snippets.

@leomp12
Last active October 13, 2021 21:10
Show Gist options
  • Save leomp12/a8ab3dd9c72aec7696e1775e349a8a70 to your computer and use it in GitHub Desktop.
Save leomp12/a8ab3dd9c72aec7696e1775e349a8a70 to your computer and use it in GitHub Desktop.
Storefront - Adicionando uma página de configuração ao CMS

Storefront - Adicionando uma página de configuração ao CMS

Para manter as opções padrão do CMS e adicionar os novos campos, a maneira mais simples é editar o arquivo template/public/admin/config.json já criado por padrão em deploys a partir do Storefront Starter.

Neste exemplo (config.json em anexo neste Gist) a configuração será acessada em /admin/#/collections/settings/entries/theme, para múltiplas páginas dentro da coleção Configurações basta adicionar mais de um objeto no array files.

Também é possível criar uma coleção nova em vez de usar a Configurações, neste caso utilize outro name e mais algumas propriedades:

{
  // ...
  name: 'theming',
  label: 'Tema',
  description: 'Configurações específicas do tema',
  delete: false,
  editor: {
    preview: false
  },
  files: [
    // ...
  ]
}

Links úteis

{
"collections": [
{
"name": "settings",
"files": [
{
"name": "theme",
"label": "Configurações do tema",
"file": "content/theme.json",
"fields": [
{
"label": "Cor da tarja",
"name": "stripe_color",
"widget": "color"
},
{
"label": "Texto do banner",
"name": "banner_text",
"widget": "string",
"hint": "Texto exibido em cima do banner principal"
}
]
}
]
}
]
}
{
"collections": [
{
"name": "blog2",
"label": "blog2",
"folder": "content/blog2",
"create": true,
"fields": [
{
"label": "Title",
"name": "title",
"widget": "string"
},
{
"label": "Publish Date",
"name": "date",
"widget": "datetime"
},
{
"label": "Featured Image",
"name": "thumbnail",
"widget": "image"
},
{
"label": "Body",
"name": "body",
"widget": "markdown"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment