diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-12 15:46:16 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-12 16:09:28 +0800 |
commit | 49b0b5eeab42fbd93bd2458c32c6170ab3edd0bf (patch) | |
tree | 6135bc9357e350f8ca7e8bb48619fe927480fa9f | |
parent | 1d631dd1a43d1c7ecb91fcc1f619e6666fdc37f8 (diff) |
refactor: add external class in generateMaps()
-rw-r--r-- | src/css/dumbymap.css | 5 | ||||
-rw-r--r-- | src/dumbymap.mjs | 10 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/css/dumbymap.css b/src/css/dumbymap.css index 7aff339..416c216 100644 --- a/src/css/dumbymap.css +++ b/src/css/dumbymap.css | |||
@@ -48,12 +48,11 @@ root { | |||
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | a[href^='http']:not(:has(img))::after, | ||
52 | .external::after { | 51 | .external::after { |
53 | content: ''; | 52 | content: ''; |
54 | display: inline-block; | 53 | display: inline-block; |
55 | width: 8px; | 54 | width: 10px; |
56 | height: 8px; | 55 | height: 10px; |
57 | margin-right: 4px; | 56 | margin-right: 4px; |
58 | margin-left: 2px; | 57 | margin-left: 2px; |
59 | 58 | ||
diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs index e5dd2cd..4a11bcb 100644 --- a/src/dumbymap.mjs +++ b/src/dumbymap.mjs | |||
@@ -177,10 +177,18 @@ export const generateMaps = (container, { | |||
177 | } | 177 | } |
178 | }) | 178 | }) |
179 | 179 | ||
180 | /** Create GeoLinks and DocLinks */ | 180 | /** Create DocLinks */ |
181 | container.querySelectorAll(docLinkSelector) | 181 | container.querySelectorAll(docLinkSelector) |
182 | .forEach(utils.createDocLink) | 182 | .forEach(utils.createDocLink) |
183 | 183 | ||
184 | /** Add external symbol on anchors */ | ||
185 | container.querySelectorAll('a') | ||
186 | .forEach(a => { | ||
187 | if (a.href.startsWith('http') && !a.href.startsWith(window.location.origin)) { | ||
188 | a.classList.add('external') | ||
189 | } | ||
190 | }) | ||
191 | |||
184 | /** Set CRS and GeoLinks */ | 192 | /** Set CRS and GeoLinks */ |
185 | register(proj4) | 193 | register(proj4) |
186 | fromEPSGCode(crs).then(projection => { | 194 | fromEPSGCode(crs).then(projection => { |