Skip to content

Commit 85a7a8d

Browse files
claudejsshin2022
authored andcommitted
Open an entry from a #station= link and add page analytics
A link such as /#station=Causal-Inference-with-Python opens that entry and, once closed, shows it in the curriculum shelf. The hash is cleared on close. The pages now load the same GA4 tag as the web book so visits can be followed across both sites.
1 parent 4ff2abb commit 85a7a8d

4 files changed

Lines changed: 41 additions & 0 deletions

File tree

‎404.html‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
<html lang="ko">
33
<head>
44
<meta charset="utf-8">
5+
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BEBVKYH8HL"></script>
6+
<script>
7+
window.dataLayer = window.dataLayer || [];
8+
function gtag(){dataLayer.push(arguments);}
9+
gtag('js', new Date());
10+
gtag('config', 'G-BEBVKYH8HL');
11+
</script>
512
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
613
<title>페이지를 찾을 수 없습니다 | Causal Inference Hub</title>
714
<link rel="icon" href="/assets/img/team-mark.png">

‎article.html‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
<html lang="ko">
33
<head>
44
<meta charset="utf-8">
5+
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BEBVKYH8HL"></script>
6+
<script>
7+
window.dataLayer = window.dataLayer || [];
8+
function gtag(){dataLayer.push(arguments);}
9+
gtag('js', new Date());
10+
gtag('config', 'G-BEBVKYH8HL');
11+
</script>
512
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
613
<title>읽을거리 | Causal Inference Hub</title>
714
<meta name="description" content="가짜연구소 인과추론팀이 쓴 글과 독자를 위한 자료입니다.">

‎assets/js/hub.js‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,21 @@
838838

839839
function closeStation() { const d = dialog(); if (d.open) d.close(); }
840840

841+
/* Deep links: #station=<repo> opens that entry, so other team sites (the web book, for one) can link straight to it. */
842+
const stationFromHash = () => {
843+
const m = location.hash.match(/^#station=(.+)$/);
844+
return m ? decodeURIComponent(m[1]) : null;
845+
};
846+
function openFromHash() {
847+
const id = stationFromHash();
848+
if (!id || !state.repos.has(id)) return;
849+
const r = state.repos.get(id);
850+
const lv = r.level && r.kind !== "paid" ? r.level : null;
851+
$("#curriculum").scrollIntoView({ behavior: "auto" });
852+
openStation(id);
853+
if (lv) dialog().addEventListener("close", () => gotoItem(id), { once: true });
854+
}
855+
841856
function toggleRide(id) {
842857
if (state.ridden.has(id)) state.ridden.delete(id); else state.ridden.add(id);
843858
saveRidden();
@@ -870,6 +885,10 @@
870885
if (open) { e.preventDefault(); openStation(open.dataset.open); }
871886
});
872887
dialog().addEventListener("click", (e) => { if (e.target === dialog()) closeStation(); });
888+
dialog().addEventListener("close", () => {
889+
if (stationFromHash()) history.replaceState(null, "", location.pathname + location.search);
890+
});
891+
window.addEventListener("hashchange", openFromHash);
873892
let t;
874893
window.addEventListener("resize", () => {
875894
clearTimeout(t);
@@ -918,6 +937,7 @@
918937
renderLegend(); renderMap(); wireTabs();
919938
renderFeatured(); renderPartner(); renderEvents(); renderArticles();
920939
if (location.hash === "#contrib") selectTab("tab-contrib");
940+
openFromHash();
921941
navSpy();
922942
refreshStars();
923943
}

‎index.html‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
<html lang="ko">
33
<head>
44
<meta charset="utf-8">
5+
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BEBVKYH8HL"></script>
6+
<script>
7+
window.dataLayer = window.dataLayer || [];
8+
function gtag(){dataLayer.push(arguments);}
9+
gtag('js', new Date());
10+
gtag('config', 'G-BEBVKYH8HL');
11+
</script>
512
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
613
<title>Causal Inference Hub | 가짜연구소 인과추론팀</title>
714
<meta name="description" content="인과추론에서 AI 시대의 데이터 리터러시까지. 가짜연구소 인과추론팀이 2022년부터 함께 만든 오픈소스와 커리큘럼을 한곳에 모은 허브입니다.">

0 commit comments

Comments
 (0)