The module cms-themeblog is the official blog theme

Plugin Dependencies

the theme module needs to explicitly specify which plugin modules are dependent.

By specifying the dependencies of the plugin modules, when the theme module is installed, the corresponding plugin modules are also automatically installed

cms-themeblog/package.json

{
  "name": "egg-born-module-cms-themeblog",
  "version": "1.1.3",
  "title": "cms:theme:blog",
  "eggBornModule": {
    "cms": {
      "name": "blog",
      "theme": true
    },
    "dependencies": {
      "a-instance": "1.0.0"
    }
  },
  ...
  "dependencies": {
    ...
    "egg-born-module-cms-pluginbase": "^1.1.0",
    "egg-born-module-cms-pluginarticle": "^1.0.0",
    "egg-born-module-cms-pluginsidebar": "^1.0.0",
    "egg-born-module-cms-pluginmarkdowngithub": "^1.0.0",
    "egg-born-module-cms-plugintrack": "^1.0.1"
  }
}
Name Description
“theme”: true indicate this is a theme module

Install Theme

$ npm i egg-born-module-cms-themeblog

Rendering Templates

15

Name Description Rendering Timing Remark
assets resource files 1
layout layout directory intermediate files you can plan and add page elements according to your own needs
main main rendering template directory 1 & 2
main/article.ejs article rendering template use this template file when you need to render an article
main/index home page rendering template directory use the template file in this directory when you need to render the home page. Why is directory? In a complex site, you can have multiple home page templates depending on the scenario
static static file directory 1 for example, the file articles.html, load articles by performing the backend API with ajax, thereby implements category, tag, search and other features concentratedly
  • 1: site wholly building
  • 2: article separately rendering
  • The theme cms-themeblog provides three main rendering templates:
    • static/articles.ejs: used to concentratedly implement features like category, tag, search, etc.
    • main/article.ejs: used for article rendering
    • main/index/index.ejs: used for home page rendering
  • assets is the resource directory: contains resources such as CSS,JS, andImage`
  • layout is the layout directory: contains rendering template of layout elements

In fact, most of the rendering template files in the layout directory are very simple, why not merge into one rendering template file?

The layout elements are divided in detail so that they can be customized more flexibly in the actual use of the theme

Layout Templates

This section focuses on the rendering templates of header and footer. For other contents, please refer to the module source code directly

layout/header.ejs

<!DOCTYPE html>
<html>
<head>
  <%- await include('./header/head.ejs') %>
</head>
<body>
  <header>
    <div class="container">
      <%- await include('./header/title.ejs') %>
      <%- await include('./header/menu.ejs') %>
    </div>
  </header>
  <div class="container container-site">

layout/header/head.ejs

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="generator" content="Cabloy-CMS" />
<link rel="shortcut icon" href="<%=url('assets/images/favicon.ico')%>" type="image/x-icon">

<%- await include('../../plugins/cms-pluginarticle/header/meta.ejs') %>
<%- await include('../../plugins/cms-pluginrss/rss.ejs') %>

<link rel="stylesheet" href="<%=url('assets/lib/bootstrap/bootstrap.min.css')%>">
<link rel="stylesheet" href="_ _CSS_ _">
_ _ENV_ _

<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->

<%
  // css
  css('../../assets/css/site.css.ejs');
  // js
  js('../../assets/js/site.js.ejs');
%>
Name Description
include include other templates, such as cms-pluginrss/rss.ejs
js declare JS file
css declare CSS file
_ CSS _ CSS placeholder
_ ENV _ env placeholder

layout/footer.ejs

  </div> <!-- container -->
  <footer>
      <span class="small">Powered by <a target="_blank" href="https://cms.cabloy.com">Cabloy-CMS</a> | Theme - <a target="_blank" href="<%=site._theme.url%>"><%=site._theme.name%></a></span>
  </footer>
  <script src="<%=url('assets/lib/jquery.min.js')%>"></script>
  <script src="<%=url('assets/lib/bootstrap/bootstrap.min.js')%>"></script>
  <script src="_ _JS_ _"></script>
</body>
</html>
Name Description
_ JS _ JS placeholder