-
-
Notifications
You must be signed in to change notification settings - Fork 12
390-feat: Add open graph previews #894
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
Merged
Merged
Changes from all commits
Commits
Show all changes
73 commits
Select commit
Hold shift + click to select a range
e4f5ab0
feat: 390 - add images for openGraph generate function
LaraNU 3e209ec
feat: 390 - implement OG image generation script for all pages
LaraNU ce91a92
docs: 390 - add generated OG image folders to .gitignore to prevent cβ¦
LaraNU 9fe67b0
fix: 390 - add missing image asset for OG generation
LaraNU 8aab59b
refactor: 390 - convert title to lowercase in generateOgImagePage forβ¦
LaraNU 0cd0f35
refactor: 390 - improve code structure by splitting generate-og-imageβ¦
LaraNU f707a8d
feat: 390 - create reusable metadata generator function
LaraNU 1ec5b1b
feat: 390 - add metadataBase for absolute URL generation for OG URLs
LaraNU b8fa55d
feat: 390 - add dynamic metadata to all pages using generatePageMetadata
LaraNU ab05327
fix: 390 - validate API_URL before course generation
LaraNU fe9c639
chore: 390 - resolve merge conflicts
LaraNU 704eaac
refactor: 390 - change data fetching approach
LaraNU 181b67c
refactor: 390 - replace if-else with ternary for date assignment
LaraNU 5832416
refactor: 390 - move and modularize generate-courses-tree logic
YulikK bb487c5
refactor: 390 - move and modularize generate-pages-tree logic
LaraNU f93c1ff
chore: 390 - resolve merge conflicts
LaraNU d681867
refactor: 390 - move UI components to view folder
LaraNU eafbb19
feat: 390 - add PNG image conversion using sharp
LaraNU 687abec
refactor: 390 - enhance schedule data with name and formatted dates
LaraNU 43f6443
feat: 390 - implement logo fetching with normalized names
LaraNU b701d4c
feat: 390 - add combined data fetching service
LaraNU 359077a
refactor: 390 - udate OG generate function
LaraNU fb908d4
refactor: 390 - relocate open-graph.data.ts to scripts
LaraNU 67af13b
refactor: 390 - remove unused images
LaraNU f6af7df
fix: 390 - fix import order in generate-og-script.ts
LaraNU 1139574
refactor: 390 - use another link for logo
LaraNU c3d0d5d
refactor: 390 - remove link
LaraNU 9c7d0ec
refactor: 390 - add error handling for file operations
LaraNU e7f9bd0
fix: 390 - fix incorrect Buffer generic type usage
LaraNU f395a12
refactor: 390 - improve execution flow and error handling
LaraNU 09d81ab
refactor: 390 - inconsistent function naming
LaraNU dcacd53
fix: 390 - fix quotation mark syntax in description
LaraNU b129fd5
refactor: 390 - consider adding error handling to the image loading fβ¦
LaraNU cad36cb
feat: 390 - consider adding image optimization options
LaraNU 9ec1aa1
fix: 390 - fix the date formatting fallback logic
LaraNU dbd488c
refactor: 390 - add fixed width
LaraNU a60d6dd
refactor: 390 - change error message
LaraNU e4bb4a2
feat: 390 - add function for generate page metadata
LaraNU 0a17097
refactor: 390 - update page descriptions
LaraNU 294cd56
feat: 390 - add standard SEO fields to course pages and main page
LaraNU 7235dd5
feat: 390 - add standard SEO fields to all pages
LaraNU d719bbe
refactor: 390 - rename image paths according to new convention
LaraNU 6f9fc9e
refactor: 390 - reorganize and consolidate course-related types
YulikK 5e24bee
refactor: 390 - consolidate OG image paths and constants
YulikK 56b0857
fix: 390 - restore ru suffix in javascript-preschool image filename
LaraNU aa58f2e
chore: 390 - resolve merge conflicts
LaraNU d42d1f0
refactor: 390 - reorganize and consolidate page-related types
LaraNU a0e48b1
refactor: 390 - change file extension from .tsx to .ts
LaraNU 76ee539
fix: 390 - eslint errors
LaraNU b775830
refactor: 390 - move API-related functions to api directory
LaraNU dbe1122
chore: 390 - resolve merge conflicts
LaraNU 1aecacd
chore: 390 - resolve merge conflicts
LaraNU 34fb1c9
feat: 390 - integrate OG image generation into src using route handler
LaraNU 633a8bb
refactor: 390 - remove comments
LaraNU be2ef96
feat: 390 - add SEO fields seoDescription and seoKeywords
LaraNU 80bfca8
feat: 390 - add OG image generation to all pages using route handler
LaraNU 8c97e49
refactor: 390 - clean up code formatting
LaraNU 002ab79
chore: 390 - resolve merge conflicts
LaraNU c8ee8ab
fix: 390 - mark new SEO fields optional and document them
LaraNU eb366e3
fix: 390 - change never on request
LaraNU 5e00dde
chore: 390 - resolve merge conflicts
LaraNU 7eb4b6e
refactor: 390 - simplify function fetchAndConvertToDataUri
LaraNU 7141e14
chore: 390 - resolve merge conflicts
LaraNU c48ea6b
refactor: 390 - added constants and moved metadata to separate files
LaraNU c928ab1
feat: 390 - add og for merch page
LaraNU 8f47891
fix: 390 - danger options
LaraNU 74c5825
refactor: 390 - remove preferredRegion and move var fontsPromis
b848d0a
refactor: 390 - use constants for metadata
6a61679
refactor: 390 - move docs metadata and upload only courses data
8962062
chore: 390 - resolve merge conflicts
aa34c88
refactor: 390 - remove comments
f82e387
fix: 390 - add width and height for image
0ff6e08
Merge branch 'main' into feat/390-add-open-graph-previews
LaraNU File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { createPageTree } from '@/shared/og/view/pages-tree/generate-pages-tree'; | ||
|
|
||
| export { DYNAMIC as dynamic } from '@/shared/constants'; | ||
|
|
||
| export async function GET() { | ||
| const title = 'Community'; | ||
| const description = 'Join the RS School developer community.'; | ||
|
|
||
| return createPageTree({ | ||
| title, | ||
| description, | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { courseStore } from '@/entities/course'; | ||
| import { resolveCoursePageLocale } from '@/entities/course/helpers/resolve-course-page-locale'; | ||
| import { coursePageStore } from '@/entities/course-page'; | ||
| import { fetchAndConvertToDataUri } from '@/shared/og/utils/fetch-and-convert-to-data-uri'; | ||
| import { loadImageAsDataUri } from '@/shared/og/utils/load-image-as-data-uri'; | ||
| import { createCourseTree } from '@/shared/og/view/courses-tree/generate-courses-tree'; | ||
|
|
||
| export const preferredRegion = 'auto'; | ||
| const fallbackPath = 'src/shared/assets/svg/rss-logo.svg'; | ||
| const logoFallbackSize = 250; | ||
|
|
||
| export async function generateStaticParams() { | ||
| const pages = await coursePageStore.loadCoursePages(); | ||
|
|
||
| return pages.map(({ slug }) => ({ slug })); | ||
| } | ||
|
|
||
| export async function GET(_request: Request, { params }: { params: Promise<{ slug: string }> }) { | ||
| const { slug } = await params; | ||
| const locale = resolveCoursePageLocale(slug); | ||
|
|
||
| const { courseName, courseId } = await coursePageStore.loadCoursePage(slug, locale); | ||
|
|
||
| const course = await courseStore.loadCourse(courseId); | ||
|
|
||
| if (!course) { | ||
| throw new Error(`Course metadata not found for id="${courseId}"`); | ||
| } | ||
|
|
||
| const logoWidth = course.iconSrc.width ?? logoFallbackSize; | ||
| const logoHeight = course.iconSrc.height ?? logoFallbackSize; | ||
| const logoCache = new Map<string, string>(); | ||
|
|
||
| let logoDataUri: string | undefined = logoCache.get(course.iconSrc.src); | ||
|
|
||
| try { | ||
| logoDataUri = await fetchAndConvertToDataUri(course.iconSrc.src); | ||
| logoCache.set(course.iconSrc.src, logoDataUri); | ||
| } catch (err) { | ||
| console.warn('Failed to load remote logo, using fallback', err); | ||
| logoDataUri = await loadImageAsDataUri(fallbackPath); | ||
| } | ||
|
|
||
| return createCourseTree({ | ||
| name: courseName, | ||
| logo: { | ||
| src: logoDataUri, | ||
| width: logoWidth, | ||
| height: logoHeight, | ||
| }, | ||
| startDate: course.startDate, | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { createPageTree } from '@/shared/og/view/pages-tree/generate-pages-tree'; | ||
|
|
||
| export { DYNAMIC as dynamic } from '@/shared/constants'; | ||
|
|
||
| export async function GET() { | ||
| const title = 'Courses'; | ||
| const description = 'Free RS School courses: JavaScript, React, Node.js, AWS, and more.'; | ||
|
|
||
| return createPageTree({ | ||
| title, | ||
| description, | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { createPageTree } from '@/shared/og/view/pages-tree/generate-pages-tree'; | ||
| import { Language } from '@/shared/types'; | ||
|
|
||
| export { DYNAMIC as dynamic } from '@/shared/constants'; | ||
|
|
||
| export function generateStaticParams() { | ||
| return [{ lang: 'en' }, { lang: 'ru' }]; | ||
| } | ||
|
|
||
| const titleMap: Record<Language, string> = { | ||
| en: 'RS School Docs', | ||
| ru: 'RS ΠΠΎΠΊΡΠΌΠ΅Π½ΡΠ°ΡΠΈΡ', | ||
| }; | ||
|
|
||
| const descriptionMap: Record<Language, string> = { | ||
| en: 'RS School Docs: rules, guides, FAQs.', | ||
| ru: 'ΠΠΎΠΊΡΠΌΠ΅Π½ΡΠ°ΡΠΈΡ RS: ΠΏΡΠ°Π²ΠΈΠ»Π°, Π³Π°ΠΉΠ΄Ρ, ΡΠ°ΡΡΠΎ Π·Π°Π΄Π°Π²Π°Π΅ΠΌΡΠ΅ Π²ΠΎΠΏΡΠΎΡΡ.', | ||
| }; | ||
|
|
||
| export async function GET(_request: Request, { params }: { params: Promise<{ lang: Language }> }) { | ||
| const lang = (await params).lang; | ||
|
|
||
| return createPageTree({ | ||
| title: titleMap[lang], | ||
| description: descriptionMap[lang], | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { createPageTree } from '@/shared/og/view/pages-tree/generate-pages-tree'; | ||
|
|
||
| export { DYNAMIC as dynamic } from '@/shared/constants'; | ||
|
|
||
| export async function GET() { | ||
| const title = 'Mentorship'; | ||
| const description = 'Mentor at RS School and help others grow.'; | ||
|
|
||
| return createPageTree({ | ||
| title, | ||
| description, | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.