fix(tl-reference): fixed html in previews, fixed some links
This commit is contained in:
parent
079d65b38d
commit
0d489574df
5 changed files with 22 additions and 5 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -89,7 +89,7 @@ export default function TlObject({ data }: { data: GraphqlResult }) {
|
|||
<meta
|
||||
name="description"
|
||||
content={
|
||||
obj.description ||
|
||||
obj.descriptionExcerpt ||
|
||||
obj.prefix +
|
||||
obj.name +
|
||||
" currently doesn't have a description."
|
||||
|
@ -281,6 +281,7 @@ export const query = graphql`
|
|||
type
|
||||
name
|
||||
description
|
||||
descriptionExcerpt
|
||||
namespace
|
||||
returns
|
||||
available
|
||||
|
|
|
@ -10,6 +10,7 @@ export interface ExtendedTlObject {
|
|||
returns: string
|
||||
underscore: string
|
||||
description: string | null
|
||||
descriptionExcerpt: string
|
||||
arguments: {
|
||||
ts: string
|
||||
optional?: boolean
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"jsx": "react"
|
||||
"jsx": "react",
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"include": "src"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue