Skip to content

Commit

Permalink
Merge pull request #274 from marko-bekhta/fix/i273-use-relative-urls-…
Browse files Browse the repository at this point in the history
…for-quarkus-origin

Use relative URLs for quarkus guides
  • Loading branch information
yrodiere authored Jun 6, 2024
2 parents 0ddb156 + ba951d6 commit 8fa331b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/main/resources/web/app/qs-guide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export class QsGuide extends LitElement {
@property({type: String}) keywords: string;
@property({type: String}) content: string | [string]
@property({type: String}) origin: string = "quarkus";
@property({type: String, attribute: 'origins-with-relative-urls'}) originsWithRelativeUrls: string[] = [];


connectedCallback() {
Expand All @@ -127,7 +128,7 @@ export class QsGuide extends LitElement {
</div>
<div>
<h4>
<a href="${this.url}" target="${this.url.startsWith('http') ? '_blank' : ''}">${this._renderHTML(this.title)}</a>
<a href="${this.relativizeUrl()}" target="_blank">${this._renderHTML(this.title)}</a>
${(this.origin && this.origin.toLowerCase() !== 'quarkus') ? html`<span class="origin ${this.origin}" title="${this.origin}"></span>` : ''}
</h4>
<div class="summary">
Expand All @@ -142,6 +143,14 @@ export class QsGuide extends LitElement {
`;
}

private relativizeUrl(): string {
if (this.originsWithRelativeUrls.includes(this.origin)) {
return this.url.substring(new URL(this.url).origin.length);
} else {
return this.url;
}
}

private icon(): string {
const icon = icons.docs[this.type];
if (icon) {
Expand All @@ -162,4 +171,4 @@ export class QsGuide extends LitElement {
}
return unsafeHTML(content);
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/web/app/qs-target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class QsTarget extends LitElement {
switch (this.type) {
case 'guide':
return html`
<qs-guide class="qs-hit" .data=${i}></qs-guide>`
<qs-guide class="qs-hit" .data=${i} origins-with-relative-urls="quarkus"></qs-guide>`
}
return ''
}
Expand Down

0 comments on commit 8fa331b

Please sign in to comment.