diff --git a/tl-reference/scripts/prepare-data.js b/tl-reference/scripts/prepare-data.js index 11589cfc..5989d0c2 100644 --- a/tl-reference/scripts/prepare-data.js +++ b/tl-reference/scripts/prepare-data.js @@ -35,6 +35,7 @@ function convertToArrays(ns) { } const marked = require('marked') +const cheerio = require('cheerio') const pascalToCamel = (s) => s[0].toLowerCase() + s.substr(1) const camelToSnake = (str) => @@ -147,8 +148,21 @@ function prepareData(data) { } // render descriptions in markdown - if (item.description) + if (item.description) { item.description = renderDescription(item.description) + item.descriptionExcerpt = cheerio.load(item.description).root().text().trim() + if (item.descriptionExcerpt.length > 100) { + const words = item.descriptionExcerpt.split(' ') + let i = 0 + let result = words[i++] + + while (result.length < 90) { + result += ' ' + words[i++] + } + + item.descriptionExcerpt = result + '...' + } + } if (item.arguments) item.arguments.forEach((arg) => { if (arg.description) diff --git a/tl-reference/src/components/objects/link-to-tl.tsx b/tl-reference/src/components/objects/link-to-tl.tsx index 771a39e9..bbfd4653 100644 --- a/tl-reference/src/components/objects/link-to-tl.tsx +++ b/tl-reference/src/components/objects/link-to-tl.tsx @@ -19,10 +19,10 @@ export function LinkToTl( history?: boolean ): React.ReactElement { if (typeof prefix !== 'string') { + history = !!type type = prefix.type name = prefix.name prefix = prefix.prefix - history = !!type } // this kind of invocation is used in parameters table and for return type diff --git a/tl-reference/src/templates/tl-object.tsx b/tl-reference/src/templates/tl-object.tsx index b1b79d7b..be01262a 100644 --- a/tl-reference/src/templates/tl-object.tsx +++ b/tl-reference/src/templates/tl-object.tsx @@ -89,7 +89,7 @@ export default function TlObject({ data }: { data: GraphqlResult }) {