diff --git a/lib/routes/rsshub/transform/json.ts b/lib/routes/rsshub/transform/json.ts index ec4ba9601d..782754738e 100644 --- a/lib/routes/rsshub/transform/json.ts +++ b/lib/routes/rsshub/transform/json.ts @@ -39,14 +39,15 @@ export const route: Route = { handler, description: `Specify options (in the format of query string) in parameter \`routeParams\` parameter to extract data from JSON. -| Key | Meaning | Accepted Values | Default | -| ------------- | ---------------------------------------- | --------------- | ------------------------------------------ | -| \`title\` | The title of the RSS | \`string\` | Extracted from home page of current domain | -| \`item\` | The JSON Path as \`item\` element | \`string\` | Entire JSON response | -| \`itemTitle\` | The JSON Path as \`title\` in \`item\` | \`string\` | None | -| \`itemLink\` | The JSON Path as \`link\` in \`item\` | \`string\` | None | -| \`itemDesc\` | The JSON Path as \`description\` in \`item\` | \`string\` | None | -| \`itemPubDate\` | The JSON Path as \`pubDate\` in \`item\` | \`string\` | None | +| Key | Meaning | Accepted Values | Default | +| ------------------ | -------------------------------------------- | ----------------- | ------------------------------------------ | +| \`title\` | The title of the RSS | \`string\` | Extracted from home page of current domain | +| \`item\` | The JSON Path as \`item\` element | \`string\` | Entire JSON response | +| \`itemTitle\` | The JSON Path as \`title\` in \`item\` | \`string\` | None | +| \`itemLink\` | The JSON Path as \`link\` in \`item\` | \`string\` | None | +| \`itemLinkPrefix\` | Optional Prefix for \`itemLink\` value | \`string\` | None | +| \`itemDesc\` | The JSON Path as \`description\` in \`item\` | \`string\` | None | +| \`itemPubDate\` | The JSON Path as \`pubDate\` in \`item\` | \`string\` | None | :::tip JSON Path only supports format like \`a.b.c\`. if you need to access arrays, like \`a[0].b\`, you can write it as \`a.0.b\`. @@ -92,6 +93,11 @@ async function handler(ctx) { const items = jsonGet(response.data, routeParams.get('item')).map((item) => { let link = jsonGet(item, routeParams.get('itemLink')).trim(); + const linkPrefix = routeParams.get('itemLinkPrefix'); + + if (link && linkPrefix) { + link = `${linkPrefix}${link}`; + } // 补全绝对链接 if (link && !link.startsWith('http')) { link = `${new URL(url).origin}${link}`;