Dcard

Markdown has limited format support, so in order to meet the specific needs of certain scenarios, Everkm Markdown supports dcard rendering. The way to use it is to use yaml/json code snippet in the markdown file, provide the dcard name and related attributes. When rendering, everkm-publish will render the final HTML using the provided context.

Format

The markdown file has the following input:

```yaml dcard/bilibili
vid: video_id
```

The above fragment declares the use of a dcard for bilibili, in the same format as the code block, but the context parameter format is only supported for json, yaml, whose content is passed as a template parameter when rendering the dcard template.

The dcard template file name is <dcard_name>.dcard.html, and the manifest file name is <dcard_name>.dcard.yaml. The same dcard resources need to be in the same directory. The theme's own dcard is stored in any subdirectory of the template directory, and the project dcard is stored in any subdirectory of the dcard directory under work_dir or dev_dir.

Referencing resource files

Normally, dcard context static content is sufficient, but in some special scenarios, e.g. when referencing an audio file in the current directory, it doesn't work as expected, because the referenced resource is not recognized, so it won't be packaged at publish time, and it won't be automatically converted to the target URL at packet time, so everkm-publish supports the use of templates in the dcard context, which makes the usage scenarios much more flexible.

For example, let's say we need to render out an audio playback. If the audio dcard is already provided in the template, we need to specify the address of the audio file via the src parameter. We also expect the referenced audio file to be automatically exported along with the published URL when it is exported for publishing. This can be done using the src function, as follows, note the use of quotes:

```yaml dcard/audio
src: "{{src(text='002 Home.mp3')}}"
```

Because referencing resource files in dcard is a high-frequency operation, everkm-publish provides syntactic sugar, such as the equivalent of the above code to the following code block:

```yaml dcard/audio
src: "$src:002 Home.mp3"
```

Prefixing the file path with $src: will automatically resolve it to the corresponding template when processing.

File paths can be absolute or relative, absolute paths use content/post/[lang] as the root directory, relative paths are based on the directory of the markdown file to which they belong.

Manifest configuration

# Name, required
name: bilibili2

# Static resources, optional
assets:
  # Resources to be injected into the page
  inject:
    - assets/b.css
    - assets/a.js
  # Resources to be published.
  files:
    - assets/**/*. {css,js}

Note: Resource paths must use relative paths based on the current manifest directory.