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 marked = require('marked')
|
||||||
|
const cheerio = require('cheerio')
|
||||||
|
|
||||||
const pascalToCamel = (s) => s[0].toLowerCase() + s.substr(1)
|
const pascalToCamel = (s) => s[0].toLowerCase() + s.substr(1)
|
||||||
const camelToSnake = (str) =>
|
const camelToSnake = (str) =>
|
||||||
|
@ -147,8 +148,21 @@ function prepareData(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// render descriptions in markdown
|
// render descriptions in markdown
|
||||||
if (item.description)
|
if (item.description) {
|
||||||
item.description = renderDescription(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)
|
if (item.arguments)
|
||||||
item.arguments.forEach((arg) => {
|
item.arguments.forEach((arg) => {
|
||||||
if (arg.description)
|
if (arg.description)
|
||||||
|
|
|
@ -19,10 +19,10 @@ export function LinkToTl(
|
||||||
history?: boolean
|
history?: boolean
|
||||||
): React.ReactElement {
|
): React.ReactElement {
|
||||||
if (typeof prefix !== 'string') {
|
if (typeof prefix !== 'string') {
|
||||||
|
history = !!type
|
||||||
type = prefix.type
|
type = prefix.type
|
||||||
name = prefix.name
|
name = prefix.name
|
||||||
prefix = prefix.prefix
|
prefix = prefix.prefix
|
||||||
history = !!type
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this kind of invocation is used in parameters table and for return 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
|
<meta
|
||||||
name="description"
|
name="description"
|
||||||
content={
|
content={
|
||||||
obj.description ||
|
obj.descriptionExcerpt ||
|
||||||
obj.prefix +
|
obj.prefix +
|
||||||
obj.name +
|
obj.name +
|
||||||
" currently doesn't have a description."
|
" currently doesn't have a description."
|
||||||
|
@ -281,6 +281,7 @@ export const query = graphql`
|
||||||
type
|
type
|
||||||
name
|
name
|
||||||
description
|
description
|
||||||
|
descriptionExcerpt
|
||||||
namespace
|
namespace
|
||||||
returns
|
returns
|
||||||
available
|
available
|
||||||
|
|
|
@ -10,6 +10,7 @@ export interface ExtendedTlObject {
|
||||||
returns: string
|
returns: string
|
||||||
underscore: string
|
underscore: string
|
||||||
description: string | null
|
description: string | null
|
||||||
|
descriptionExcerpt: string
|
||||||
arguments: {
|
arguments: {
|
||||||
ts: string
|
ts: string
|
||||||
optional?: boolean
|
optional?: boolean
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.json",
|
"extends": "../tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"jsx": "react"
|
"jsx": "react",
|
||||||
|
"esModuleInterop": true
|
||||||
},
|
},
|
||||||
"include": "src"
|
"include": "src"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue