| | import { Liquid } from 'liquidjs' |
| | import GithubSlugger from 'github-slugger' |
| | |
| | import Data from './data' |
| | import Octicon from './octicon' |
| | |
| | import Ifversion from './ifversion' |
| | |
| | import { Tool, tags as toolTags } from './tool' |
| | import { Spotlight, tags as spotlightTags } from './spotlight' |
| | import { Prompt } from './prompt' |
| | import IndentedDataReference from './indented-data-reference' |
| | import { apiTransformerTags } from '@/article-api/liquid-renderers' |
| |
|
| | |
| | |
| | const anyData = Data as any |
| | const anyIfversion = Ifversion as any |
| | const anyTool = Tool as any |
| | const anySpotlight = Spotlight as any |
| | const anyPrompt = Prompt as any |
| | const anyIndentedDataReference = IndentedDataReference as any |
| |
|
| | export const engine = new Liquid({ |
| | extname: '.html', |
| | dynamicPartials: false, |
| | }) |
| |
|
| | engine.registerTag('indented_data_reference', anyIndentedDataReference) |
| | engine.registerTag('data', anyData) |
| | engine.registerTag('octicon', Octicon) |
| | engine.registerTag('ifversion', anyIfversion) |
| |
|
| | for (const tag of toolTags) { |
| | engine.registerTag(tag, anyTool) |
| | } |
| |
|
| | for (const tag in spotlightTags) { |
| | engine.registerTag(tag, anySpotlight) |
| | } |
| |
|
| | engine.registerTag('prompt', anyPrompt) |
| |
|
| | |
| | for (const [tagName, tagClass] of Object.entries(apiTransformerTags)) { |
| | engine.registerTag(tagName, tagClass as any) |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | engine.registerFilter('obj_size', (input: Record<string, unknown> | null | undefined): number => { |
| | if (!input) return 0 |
| | return Object.keys(input).length |
| | }) |
| |
|
| | |
| | |
| | |
| | |
| | engine.registerFilter('version_num', (input: string): string => { |
| | return input.split('@')[1] |
| | }) |
| |
|
| | |
| | |
| | |
| | engine.registerFilter('slugify', (input: string): string => { |
| | const slugger = new GithubSlugger() |
| | return slugger.slug(input) |
| | }) |
| |
|