docs: fix external link display text (#6323)

This commit is contained in:
CSY54 2022-08-03 17:54:58 +08:00 committed by GitHub
parent f8a9fa7b67
commit d1cc5cca69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
import { splitByCase, upperFirst } from 'scule'
export default (title, link) => {
return title || link.split('/').filter(Boolean).map(part => splitByCase(part).map(p => upperFirst(p)).join(' ')).join(' > ').replace('Api', 'API')
return title || (link.startsWith('http') && link) || link.split('/').filter(Boolean).map(part => splitByCase(part).map(p => upperFirst(p)).join(' ')).join(' > ').replace('Api', 'API')
}