Customized templates

Quick Start

You can refer to the official template project: https://github.com/everkm/theme-yilog

Workspace 👉 Directory structure

# Install
pnpm add everkm-publish

# Startup
everkm-publish serve --dev-dir ./

Browser visit http://localhost:9081

Configuration file

filename: everkm-theme.yaml

name: yilog
version: 0.0.1
author: dayu<dayu@dayu.me>
repository: https://github.com/daobox-theme/yilog
demo: https://yilog.theme.everkm.com/

# Overrides with the same name can be configured via `everkm.yaml`.
map_url:
sitemap:

Parameters:

  • name The name of the template.
  • version Version
  • author Author
  • repository Code repository
  • demo Demo address
  • map_url As same as workspace configurtion map_url
  • sitemap As same as workspace configurtion sitemap

Commands

Theme management

Usage: everkm-publish theme <COMMAND>

Commands:
  package  Theme package
  install  Install theme
  help     Print this message or the help of the given subcommand(s)

Options:
  -h, --help  Print help

Template Multi-Language

Text

Everkm language packs are stored in markdown file format, with the first level title as the key, the area under the key is the corresponding content, and the blanks at both ends are automatically ignored.

  1. Language pack storage location

    In the <base dir>/src/templates/ directory or any of its subdirectories.

  2. File naming conventions

    <Language Code>.i18n.md, If you need to use a namespace, name it <Namespace>.<Language Code>.i18n.md。 For example

    en_US.i18n.md

    # My name
    Everkm Publish
    

    details.en_US.i18n.md

    # toc
    Table Of Contents
    
  3. How it is used in the template

    Read by built-in function [t] (builtin-function#t). Language packs with namespaces need to be prefixed with <namespace>: , noting that there is a space after it.

    <p>{{t(text="My name")}}</p>
    <p>{{t(text="details: toc")}}</p>
    

    Output

    <p>Everkm Publish</p>
    <p>Table Of Contents</p>
    

Images

When the image needs to be switched according to the language, proceed as follows:

  1. In the same directory as the image, place the image to be replaced, with the same filename, and add . <Language Code> language fragment before the extension.

  2. Use the built-in function imgsrc in templates to handle image addresses. For example

    <img src="{{img_src(file='logo.png')}}" />
    

    The corresponding English (--lang=en_US) image output is

    <img src="logo.en_US.png" />