-
-
Notifications
You must be signed in to change notification settings - Fork 124
[Feature] Incorporate video link with headings #985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for nature-of-code-2nd-edition ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for nature-of-code-pdf ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
[Notion] Update docs
This is great, thank you @jasongao97! Two comments / questions:
|
I think (for now) we can safely assume that the links will only ever point to
Yes, looks great! @tuantinghuang feel free to weigh in, we can always adjust the design later. @jasongao97 if we can just remove the thumb from notion and bring it in here to this branch then I'll merge! |
(Also, I'm going to take out the video number text in Notion, I think it's not important or relevant and just confuses things since the book has its own numbering system. The videos are just supplemental and appear wherever I happen to have something that matches what is being discussed in the text.) |
Yes, Got it!
I am adding this. |
@shiffman I am wondering if thumbnail file be named as the callout's title in e.g. the 'What is a vector?' in Chapter 1 video's file would be |
Yes that sounds good! |
Hi @jasongao97 I have a new idea! Take a look at @fturmel's automated download of YT thumbnails in CodingTrain/thecodingtrain.com#1646 as well as CodingTrain/thecodingtrain.com#1645 (comment). I wonder if we have the ID for each video embedded in Notion we could automate the retrieval of the thumb? If it would simplify things (and maybe it's actually better for the end user experience to get to the YT page directly) we could embed the YT videos in Notion (then we have direct access to the video ID) rather than the Coding Train webpage? What do you think? |
If I understand correctly, this is only for hover states on the web version, no print/PDF? Will the videos linked always be known to the Coding Train site (either via YouTube or Coding Train links)? Here's an idea: if you're OK sharing bandwidth between both sites, it would make sense to put the responsibility of the Coding Train site to recommend a thumbnail to use. We could generate a lookup/manifest file that has all urls, youtube ids and thumbnail images known to the site. The NoC site loads the manifest at runtime so it's always in sync. Images could also be loaded directly from thecodingtrain.com if we add the proper CORS header. Something like this with O(1) lookups to the thumbnail index: {
"thumbnails": ["https://thecodingtrain.com/static/c8098520739212b37e99d0c131d4a6ba/bb8ee/index.png"],
"urls": {
"https://thecodingtrain.com/challenges/180-falling-sand": 0
},
"youtubeIds": {
"L4u7Zy_b868": 0
}
} or just a simple array, slower lookups but the relationship between the data is kept: [
{
"url": "https://thecodingtrain.com/challenges/180-falling-sand",
"thumbnail": "https://thecodingtrain.com/static/c8098520739212b37e99d0c131d4a6ba/bb8ee/index.png",
"youtubeId": "L4u7Zy_b868"
}
] |
Based on my understanding, can confirm:
Yes
Ideally, yes, the link will be either to a video page on the website, or a YouTube video, and the video should have a corresponding page on the site |
This is correct. I am trying to decide whether the link should go to thecodingtrain.com or youtube.com, I'm still on the fence about this.
Yes, I am fine with thecodingtrain.com being responsible for hosting / providing the thumb image for the hover. The Nature of Code site, however, is built in a non-traditional way via a GitHub action. The action pulls everything from a Notion database and builds the HTML pages. The goal here is to include a single URL in Notion (coding train page or youtube video). |
What I was suggesting would work regardless of the NoC build system since it's all in-browser (client-side). The lookup would be created during the Coding Train builds. The NoC site would load the lookup JSON once in browser and the VideoLink React component would then be able to determine the thumbnail to use based on the video URL and lookup. It would allow using Coding Train URLs in Notion without the need for additional thumbnail information. It also means the NoC codebase would not need to keep these mappings or images locally. Also relevant, as long as you use a resolution of WebP:
Hope this makes sense! EDIT: Sorry for all the rambling, I'm going to stop now 🤪 I just wanted to clarify that while the fetch-notion repo does builds HTML, the NoC codebase also has its build phase and can augment these HTML elements with React components depending on their noc-book-2/src/layouts/ChapterLayout.js Lines 13 to 38 in daca3bb
|
One last idea (for real this time), which I think is possibly the best one because it's simple and could be really useful outside of the scope of this integration. We could add redirect shortcuts on the Coding Train site just like the numerical shortcuts for challenges (see CodingTrain/thecodingtrain.com#1556) ex: The NoC project could store only the YouTube ID or URL in Notion. You then have enough information to link to either YouTube or the Coding Train shortcut (or both). And you can directly use the YouTube CDN image as I previously described. |
Yes, this is perfect! What do you think @jasongao97? I do think that we should pull the thumbnails and store them locally here at build time, however, rather than have the website embed the YouTube CDN link? We're doing that with everything that is in Notion already so might as well with YouTube images as well. How do you envision automating the redirects @fturmel? For now @jasongao97 I think we should just embed the YT url and then we can update to use CT links later if we want. You can pull the ID from the url and then grab the thumbnail via the methods discussed in CodingTrain/thecodingtrain.com#1645. |
What will be finally linked on the NoC website? The YT video, or the page on theCodingTrain.com? |
I'd like it to be possible to be either eventually but I think I'll start with YT video as in the sample. |
@shiffman On the Coding Train site, my initial thought was just to create the YouTube ID to URL mapping at build time and dump them in the We were discussing Netlify Edge Functions yesterday, and it seems like it would be a good fit. The YouTube ID to URL mapping would still be created at build time but the output would be a JSON file that gets bundled and deployed with the function itself. We'd have one rewrite rule to add in Because a YouTube video can appear in challenges and/or multiple tracks, we'll need to prioritize where the redirect goes. As was discussed back when we implemented the canonical track feature, we'd pick the first match in this order:
For multi-part videos like the Rubik's Cube challenge, we can append the proper anchor to the destination ( The end result would be for example The NoC site would simply link to |
I just want to confirm my understanding. There are two types of URLs from Notion, and here's how they will be processed:
Additionally: Since the download images action can be time-consuming and doesn't occur frequently, perhaps we could separate it into another GitHub action to be triggered as needed. |
@jasongao97 That could work too. My mental model was more:
And then if we go ahead and implement the |
Yes what @fturmel suggests make sense to me. Let's make this work first with just YT video links directly. We can add support for ct.com links as a second step. if it simplifies things for the image to come from the YT CDN rather than a local copy I'm good with that! Id like to get this merged with the simplest working version as soon as possible so I can move onto running other site updates. Thank you all!! |
I've added the feature of displaying the thumbnail get from the YouTube CDN. Preview Link: https://deploy-preview-985--nature-of-code-2nd-edition.netlify.app/vectors/#vector-addition |
Fantastic!!! |
Implementation of #946
Without Image
=>
With Image
=>