Skip to content

Commit 4e660b1

Browse files
add external link to Vehicles see also
1 parent 85ed56e commit 4e660b1

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

web/src/components/SeeAlsoSection.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ const { seeAlsoLinks, currentId } = Astro.props;
2121
{link.name === currentId ? (
2222
<strong>{link.name.replace(/_/g, ' ')}</strong>
2323
) : (
24-
<a href={link.link}>{link.name.replace(/_/g, ' ')}</a>
24+
<a target={link.newTab ? '_blank' : '_self'}
25+
rel={link.newTab ? 'noopener noreferrer' : undefined}
26+
href={link.link}>{link.name.replace(/_/g, ' ')}</a>
2527
)}
2628
</li>
2729
))}

web/src/pages/reference/ID_Lists/Vehicles.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,8 @@ fourDoorVehicles = { -- boats and bikes not included
455455

456456
<SeeAlsoSection seeAlsoLinks={getSeeAlsoLinksFromList([
457457
'reference:ID_Lists',
458+
'reference:vehicle',
459+
'external:Web Vehicle 3D Model Viewer:http://gta.rockstarvision.com/vehicleviewer/#sa'
458460
])} currentId='' />
459461
</StarlightPage>
460462

web/src/utils/general.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export function renderInlineMarkdown(markdown: string): string | Promise<string>
2424
type SeeAlsoLink = {
2525
name: string;
2626
link: string;
27+
newTab?: boolean;
2728
};
2829

2930
export type SeeAlsoLinkGroup = {
@@ -108,6 +109,14 @@ export function getSeeAlsoLinksFromList(seeAlsoList: string[]): SeeAlsoLinkGroup
108109
groupedMap.get(title)!.push({ name: refPage, link: `/reference/${refPage}` });
109110
continue;
110111
}
112+
if (type === 'external') {
113+
const title = rest[0];
114+
const httpprefix = rest[1];
115+
const url = httpprefix + ':' + rest[2];
116+
if (!groupedMap.has('Links')) groupedMap.set('Links', []);
117+
groupedMap.get('Links')!.push({ name: title, link: url, newTab: true });
118+
continue;
119+
}
111120

112121
// Handle function/event style links
113122
const [subType, category] = rest;
@@ -128,6 +137,7 @@ export function getSeeAlsoLinksFromList(seeAlsoList: string[]): SeeAlsoLinkGroup
128137
if (!type || rest.length === 0) return null;
129138
if (type === 'article') return 'Articles';
130139
if (type === 'reference') return 'Reference';
140+
if (type === 'external') return 'Links';
131141
return makeTitle(rest[0], rest[1], type);
132142
})
133143
.filter((title): title is string => title !== null)

0 commit comments

Comments
 (0)