如何在撇号 cms 主题中添加字体 site.less

how to add fonts in apostrophe cms theme site.less

我已经在主题中添加了字体,但仍然出现 404。

import "utils/reset.less";

@apos-ui-font-path: '/modules/theme/public/css/font-awesome/fonts/';
.apos-add-font('roboto', @apos-ui-font-path + 'roboto-regular-webfont');


    // Delete the boilerplate CSS below when you are ready to dive in and customize your sites        
body { background-color: @apos-white;
        }

.main-content {
  margin: 200px auto;
  padding: 20px;
  max-width: 500px;
  color: @apos-white;
  background-color: @apos-primary;
  .apos-drop-shadow;

  .login-link {
    float: right;
    color: @apos-white;
  }

  // Basic rich-text editor styles:
  h3 {
    font-size: 24px;
    margin-bottom: 12px;
  }

  h4 {
    font-size: 20px;
    margin-bottom: 10px;
  }

  strong { font-weight: bold; }
  em { font-style: italic; }
}

我也附上了我的 index.js

module.exports = {
  construct: function(self, options) {
    // loads from public/js/site.js of this module
    self.pushAsset('script', 'popper');
    self.pushAsset('script', 'bootstrap.min');
    self.pushAsset('script', 'particles');
    self.pushAsset('script', 'custom');
    // loads from public/css/site.less of this module
    self.pushAsset('stylesheet', 'jquery-3.2.1.min');
    self.pushAsset('stylesheet', 'bootstrap.min');
    self.pushAsset('stylesheet', 'font-awesome/font-awesome.min');
    self.pushAsset('stylesheet', 'style');
    self.pushAsset('stylesheet', 'site');

  }
};

我是不是错过了什么,因为我的字体不适用于撇号 cms?或者路径不正确?我如何在主题中提供字体的相对路径

提前致谢

您是否尝试过将 URL 中的“/public”删除到您的字体中。有关示例,请参见 tutorial page

这段代码解决了我的问题。

@font-face {
    font-family: 'Roboto-Regular';;
    src: url('/modules/mytheme/fonts/Roboto-Regular.woff') format('woff');
  }
@font-face {
    font-family: 'Roboto-Light';;
    src: url('/modules/mytheme/fonts/Roboto-Light.woff') format('woff');
}