Skip to content

Commit

Permalink
anchor links to talks
Browse files Browse the repository at this point in the history
  • Loading branch information
samipe committed Nov 12, 2024
1 parent 6ad854c commit 58fa645
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 39 deletions.
71 changes: 40 additions & 31 deletions docs/assets/index-CCRmWWb_.js → docs/assets/index-CrYJf5QC.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/assets/index-Dx3dn50d.css

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/assets/index-DxosgorO.css

This file was deleted.

4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>RoboCon - Robot Framework Conference</title>
<script defer src="/spa.js"></script>
<script type="module" crossorigin src="/assets/index-CCRmWWb_.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DxosgorO.css">
<script type="module" crossorigin src="/assets/index-CrYJf5QC.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-Dx3dn50d.css">
</head>
<body>
<div id="app"></div>
Expand Down
4 changes: 4 additions & 0 deletions src/assets/css/grid.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
height: 100%;
}

.h-fit {
height: fit-content;
}

.sticky {
position: sticky;
}
Expand Down
20 changes: 19 additions & 1 deletion src/components/PretalxSchedule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

<script setup lang="ts">
import type { PretalxSchedule } from '@/content';
import { computed, ref, type PropType } from 'vue';
import { computed, nextTick, ref, type PropType } from 'vue';
import { useFetch } from '@vueuse/core'
import TalkItem from './TalkItem.vue'
import type { PretalxEvent, PretalxSession, ScheduleResponse, SubmissionsResponse } from '@/types/pretalx';
Expand All @@ -73,6 +73,14 @@ const talks = computed(() => {
const schedule = data.value as ScheduleResponse
const submissions = dataSub.value as SubmissionsResponse
nextTick(() => {
const hash = window.location.hash
if (hash) {
const talkTitle = document.getElementById(hash.slice(1))
if (talkTitle) talkTitle.scrollIntoView()
}
})
const addSubmissionData = (event: PretalxEvent): PretalxEvent & PretalxSession => ({...event, ...submissions.results.find((s) => s.code === event.code)})
return {
live: sortTalks(schedule.slots.filter((talk) => talk?.slot?.room?.en === 'RoboCon').map((event) => addSubmissionData(event))),
Expand All @@ -81,6 +89,16 @@ const talks = computed(() => {
online: sortTalks(schedule.slots.filter((talk) => talk?.slot?.room?.en === 'RoboCon Online' && ['PreRecorded-Talk', 'Talk'].includes(talk.submission_type.en)).map((event) => addSubmissionData(event)))
}
})
const hash = window.location.hash
if (hash) {
if (hash.includes('live-')) {
shownTalks.value = 'live'
}
if (hash.includes('online-')) {
shownTalks.value = 'online'
}
}
// .sort((a, b) => {
// if (new Date(a.slot?.start || a.start) < new Date(b.slot?.start || b.start)) return -1
// return 1
Expand Down
21 changes: 17 additions & 4 deletions src/components/TalkItem.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<article class="event mb-medium p-medium pt-none">
<div class="pt-xsmall pb-2xsmall" style="margin-left: -0.75rem">
<div class="badge">
<div class="pt-xsmall pb-2xsmall flex between" style="margin-left: -0.75rem">
<div class="badge h-fit">
<template v-if="event.type === 'break'">
Break
</template>
Expand All @@ -12,8 +12,11 @@
{{ getEventType(event.submission_type.en) }}
</template>
</div>
<a v-if="event.type === 'talk'" :href="`#${getSlug(event)}`">
<link-icon style="transform: translateY(2px)" color="black" />
</a>
</div>
<h1 v-if="event.type === 'talk'" class="mb-2xsmall">
<h1 v-if="event.type === 'talk'" class="mb-2xsmall" :id="getSlug(event)">
{{ event.title }}
</h1>
<h1 v-else-if="event.type === 'break'" class="mb-2xsmall">
Expand Down Expand Up @@ -51,22 +54,32 @@ import { renderMarkdown } from 'Content/renderContent';
import { type PropType } from 'vue'
import type { PretalxEvent, Break } from '@/types/pretalx';
import SpeakerItem from './SpeakerItem.vue'
import LinkIcon from './icons/LinkIcon.vue'
const getEventType = (type: string) => {
if (type === 'PreRecorded-Talk') return 'Talk'
return type
}
defineProps({
const props = defineProps({
event: Object as PropType<PretalxEvent | Break>
})
const getSlug = (event: PretalxEvent) => {
if (!event.title) return ''
if (props.event.type === 'break') return
const isLive = props.event.slot.room.en === 'RoboCon' || props.event.submission_type.en === 'Workshop - Full Day'
if (isLive) return `live-${event.title.replace(/[ ]/g, '-').replace(/[^a-zA-Z0-9-]/g, '').toLowerCase()}`
return `online-${event.title.replace(/[ ]/g, '-').replace(/[^a-zA-Z0-9-]/g, '').toLowerCase()}`
}
</script>

<style scoped>
h1 {
line-height: 1.35;
scroll-margin-top: 8rem;
}
.event {
border: solid 0px var(--color-theme-secondary);
Expand Down

0 comments on commit 58fa645

Please sign in to comment.