diff --git a/src/components/ExportToJsonLink.astro b/src/components/ExportToJsonLink.astro new file mode 100644 index 0000000..6f14730 --- /dev/null +++ b/src/components/ExportToJsonLink.astro @@ -0,0 +1,36 @@ +--- +import type { PlaylistSnapshot } from '@/models/playlist-snapshot'; + +interface Props { + snapshot: PlaylistSnapshot; +} + +const { snapshot } = Astro.props; +--- + + + + + + + Export to JSON + + diff --git a/src/components/vue/CopyTrackUrlsButton.vue b/src/components/vue/CopyTrackUrlsButton.vue new file mode 100644 index 0000000..d61f288 --- /dev/null +++ b/src/components/vue/CopyTrackUrlsButton.vue @@ -0,0 +1,69 @@ + + + diff --git a/src/pages/playlists/[playlistId]/snapshots/[commitSha].astro b/src/pages/playlists/[playlistId]/snapshots/[commitSha].astro index 107a9ae..c3aade3 100644 --- a/src/pages/playlists/[playlistId]/snapshots/[commitSha].astro +++ b/src/pages/playlists/[playlistId]/snapshots/[commitSha].astro @@ -6,11 +6,15 @@ import PlaylistPageTab from '@/layouts/PlaylistPageTab.astro'; import { getPlaylistLayoutProps } from '@/utils/getPlaylistLayoutProps'; import { formatDate } from '@/utils/formatDate'; +import CopyTrackUrlsButton from '@/components/vue/CopyTrackUrlsButton.vue'; +import ExportToJsonLink from '@/components/ExportToJsonLink.astro'; + import type { PlaylistSnapshot } from '@/models/playlist-snapshot'; const layoutProps = await getPlaylistLayoutProps(Astro); let snapshot: PlaylistSnapshot | null = null; +let trackUrls: string[] = []; if (layoutProps.playlist) { try { @@ -24,6 +28,7 @@ if (layoutProps.playlist) { } snapshot = (await githubResponse.json()) as PlaylistSnapshot; + trackUrls = snapshot.tracks.map(({ url }) => url); layoutProps.description = decode(snapshot.description, { level: 'html5' }); } catch (error) { const isNotFoundError = (error as Error).message === 'GitHub 404'; @@ -42,9 +47,13 @@ if (layoutProps.playlist) {

{layoutProps.description}

+
+ + +