Estrutura de temas e componentes de tema

O Discourse suporta temas nativos que podem ser obtidos a partir de um arquivo .tar.gz ou de um repositório git remoto, incluindo repositórios privados.

Um exemplo de tema está disponível em: GitHub - discourse/discourse-simple-theme: Sam's simple discourse theme · GitHub

O repositório git será verificado em busca de atualizações (uma vez por dia) ou usando o botão Verificar Atualizações. Quando alterações forem detectadas, o botão Verificar Atualizações será alterado para Atualizar para a Versão Mais Recente.

image

Para criar um tema, você precisa seguir uma estrutura de arquivos específica. Estes são os arquivos que você pode incluir:

about.json (obrigatório)

common/common.scss
common/header.html
common/after_header.html
common/footer.html
common/head_tag.html
common/body_tag.html
common/embedded.scss

desktop/desktop.scss
desktop/header.html
desktop/after_header.html
desktop/footer.html
desktop/head_tag.html
desktop/body_tag.html

mobile/mobile.scss
mobile/header.html
mobile/after_header.html
mobile/footer.html
mobile/head_tag.html
mobile/body_tag.html

locales/en.yml
locales/{locale}.yml

stylesheets/{anything}/{anything}/{anything}.scss

javascripts/{anything}.js
javascripts/{anything}.gjs
javascripts/{anything}.hbs

assets/{asset_filename}

settings.yml

Qualquer um desses arquivos :arrow_up: é opcional, então você só precisa criar os que forem necessários.

Para quem deseja dividir os arquivos SCSS do tema em múltiplos arquivos, isso agora é possível.

Para quem deseja dividir o tema em múltiplos arquivos JS, basta adicionar os arquivos JS desejados no diretório javascripts.

A estrutura do arquivo about.json está abaixo, e você pode ver mais informações sobre ele em https://meta.discourse.org/t/adding-metadata-to-a-theme/119205:

{
  "name": "Meu Tema",
  "component": false,
  "license_url": null,
  "about_url": null,
  "authors": null,
  "theme_version": null,
  "minimum_discourse_version": null,
  "maximum_discourse_version": null,
  "assets": {
    "variable-name": "assets/my-asset.jpg"
  },
  "color_schemes": {
    "Meu Esquema de Cores": {
      "primary": "222222"
    }
  },
  "screenshots": ["screenshots/light.jpeg", "screenshots/dark.jpeg"]
}

Instruções sobre como adicionar configurações ao seu tema estão disponíveis aqui: Add settings to your Discourse theme.

Para informar ao Discourse que você vai adicionar um componente de tema e não um tema completo, basta adicionar a linha "component": true ao arquivo about.json.

A estrutura de arquivos corresponde às personalizações de CSS/HTML do tema.

Leitura adicional

Confira os outros artigos com a tag #themes::tag.

:information_source: Veja também:


Última revisão por @SaraDev em 2022-08-15T21:00:00Z


Este documento está sob controle de versão — sugira alterações no GitHub.

62 curtidas
Alien Night Theme - A free Dark Theme for Discourse
Override values for auto-generated color variables
How to modify the header HTML, but still remaining the default founctions
Custom user fields show on Activity, but not Summary page
Add Unsolved button to top menu using custom HTML
Add support for theme settings
Create and share a font theme component
Color Scheme Contest (with Prizes!)
How do I get started with Discourse development as a regular end user with no programming experience?
Custom assets upload folder?
Some basic questions about discourse and rails
Create and share a color scheme
Split up theme SCSS into multiple files
Theme Developer Quick Reference Guide
Theme Developer Tutorial: 2. Creating a remote theme
Mobile View Loading different HTML as compared to Desktop
Developing Discourse Themes & Theme Components
Minimizing Maintenance on Theme Customizations
Need help with theme component Github
Allow users to select new color palettes
Challenges creating a custom color palette
Adding metadata and screenshots to a Theme
Push to digital ocean from command line and rebuild
Battle Axe - A free theme by the Tappara.co hockey community
Beginner's guide to using Discourse Themes
Discourse deployment using github or bitbucket?
How to remove sticky top bar?
Do you have original customisations?
Add custom content that only appears on your homepage
Highlight color
Timefuser Theme
Compact member list
Understanding the development/deployment process
CSS Theme Contest (with Prizes!)
How to bring in Latest topics when using category boxes
Need to include PGN (chess game notation) in a post
Custom header colour and category icons and login button
Automatic dark mode for embedded comments as well?
Add settings to your Discourse theme
Designer's Guide to getting started with themes in Discourse