Pulls content from external APIs and injects it into the Shevky build pipeline. Includes a mapping language, pagination, and request controls.
- Fetches remote content during build
- Flexible field mapping and transformations
- Pagination support (page, offset, cursor)
- Request settings (method, headers, body, timeout)
npm i @shevky/plugin-content-bridgeAdd the plugin to your Shevky config:
{
"plugins": [
"@shevky/plugin-content-bridge"
]
}Add plugin config in site.json (recommended: sources):
{
"pluginConfigs": {
"shevky-content-bridge": {
"maxItems": 10,
"sources": [
{
"name": "posts",
"fetch": {
"endpointUrl": "https://dummyjson.com/posts",
"method": "GET",
"headers": {},
"timeoutMs": 30000,
"pagination": {
"pageParam": "skip",
"sizeParam": "limit",
"pageIndexStart": 0,
"pageSize": 10,
"itemsPath": "$_posts",
"totalPath": "$_total"
}
},
"mapping": {
"frontMatter": {
"id": "$_id",
"lang": "tr",
"title": "$_title",
"slug": "$slugify($_title)",
"canonical": "$concat('~/', $slugify($_title))",
"template": "post",
"layout": "default",
"status": "published",
"featured": true,
"tags": "$_tags",
"date": "$now()",
"description": "$_title",
"category": "$_tags[0]"
},
"content": "$_body",
"sourcePath": "$concat('bridge://dummyjson/posts/', $_id, '.md')"
},
"maxItems": 5
}
]
}
}
}Use sources to fetch from multiple APIs. Each source has its own fetch and mapping.
sources: Array of{ name?, fetch, mapping, maxItems? }maxItems: Optional global limit (applies to all sources)
endpointUrl: API URL (required)method:GETorPOST(defaultGET)headers: Request headersbody: POST body (string or object). Objects are JSON-stringified.timeoutMs: Request timeout in ms (default30000)pagination: Optional. Enables multi-page fetching.
pageParam: Page parameter (page,skip,offset, etc.)sizeParam: Page size parameter (limit,pageSize, etc.)pageIndexStart: Start index (e.g. 0 or 1)pageIndexStep: Increment size. Inoffsetmode, usuallypageSize.pageSize: Page sizedelayMs: Delay between requestsitemsPath: Path to the array in the response (e.g.$_posts)totalPath: Path to the total count (e.g.$_total)hasMorePath: Boolean continuation flagnextPagePath: Next page numbernextCursorPath: Cursor valuecursorParam: Cursor parametercursorStart: Initial cursor valuemode:page|offset|cursor
Mode explanation:
page: page number increments by 1 (page=1,2,3)offset: index is an offset and increases bypageSize(skip=0,10,20)cursor: usesnextCursorPathand sends it viacursorParam
If pageParam is skip or offset, mode is inferred as offset.
Continuation priority:
nextCursorPathhasMorePathnextPagePathtotalPath- Short page check (
items.length < pageSize)
frontMatter: Maps Shevky front matter fieldscontent: Content body (markdown)sourcePath: Source path (required)
maxItems: Optional. Global limit for the plugin. Each source can override it with its ownmaxItems.
Field references:
$_fieldreads from source$_tags[0]reads array element'text'is a literal string$slugify($_title)calls a function (functions can be nested)
Functions:
$slugify(value)-> URL-safe slug$concat(a, b, c...)-> joins values into one string$lower(value)-> lowercase string$upper(value)-> uppercase string$trim(value)-> trims whitespace$join(array, separator)-> joins array into a string$date(value, format)-> formats a date; noformatreturns ISO$now()-> current datetime in ISO$today()-> current datetime in ISO (same as$now)$number(value)-> parses to number (invalid ->undefined)$boolean(value)-> normalizes truthy values$default(value, fallback)-> fallback if value is empty$replace(value, from, to)-> string replace (all occurrences)$merge(array1, array2, ...)-> merges arrays$unique(array)-> removes duplicates$nanoid(length)-> random id$uuid()-> random UUID (v4)
$date format tokens: YYYY, MM, DD, HH, mm, ss.
idlangtitleslugcanonicaltemplatelayoutstatus
MIT