mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
Fix links for docs (#2908)
* fix docs paths * docsLink directive * fix: bugs (#2909) --------- Co-authored-by: Alex Inkin <alexander@inkin.ru>
This commit is contained in:
31
web/projects/shared/src/directives/docs-link.directive.ts
Normal file
31
web/projects/shared/src/directives/docs-link.directive.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import {
|
||||
computed,
|
||||
Directive,
|
||||
inject,
|
||||
InjectionToken,
|
||||
input,
|
||||
} from '@angular/core'
|
||||
|
||||
const HOST = 'https://staging.docs.start9.com'
|
||||
export const VERSION = new InjectionToken<string>('VERSION')
|
||||
|
||||
@Directive({
|
||||
selector: '[docsLink]',
|
||||
standalone: true,
|
||||
host: {
|
||||
target: '_blank',
|
||||
rel: 'noreferrer',
|
||||
'[href]': 'url()',
|
||||
},
|
||||
})
|
||||
export class DocsLinkDirective {
|
||||
private readonly version = inject(VERSION)
|
||||
|
||||
readonly href = input.required<string>()
|
||||
|
||||
protected readonly url = computed(() => {
|
||||
const path = this.href()
|
||||
const relative = path.startsWith('/') ? path : `/${path}`
|
||||
return `${HOST}${relative}?os=${this.version}`
|
||||
})
|
||||
}
|
||||
@@ -13,6 +13,7 @@ export * from './components/markdown.component'
|
||||
export * from './components/prompt.component'
|
||||
export * from './components/server.component'
|
||||
|
||||
export * from './directives/docs-link.directive'
|
||||
export * from './directives/drag-scroller.directive'
|
||||
export * from './directives/safe-links.directive'
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ export function getErrorMessage(e: HttpError | string, link?: string): string {
|
||||
'Request Error. Your browser blocked the request. This is usually caused by a corrupt browser cache or an overly aggressive ad blocker. Please clear your browser cache and/or adjust your ad blocker and try again'
|
||||
} else if (!e.message) {
|
||||
message = 'Unknown Error'
|
||||
link = 'https://docs.start9.com/latest/support/faq'
|
||||
link = 'https://docs.start9.com/help/common-issues.html'
|
||||
} else {
|
||||
message = e.message
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user