mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +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}`
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user