-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: feed detail page seo #10
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 13 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
da247fe
new favicon
Alessandro100 52fafbb
tidy up
Alessandro100 d31f21b
structured data additions
Alessandro100 8648f79
updated metadata
Alessandro100 c7a78e5
decoupled initial css loading
Alessandro100 8742f1e
map nav fix + styling
Alessandro100 a2a5935
seo friendly header
Alessandro100 9dc0a9e
tidy + comments
Alessandro100 2db866f
dataset history styling + seo
Alessandro100 6729ce1
feeds search next link
Alessandro100 f75575d
feed summary header hiearchy
Alessandro100 1740177
feedview lazy load not essential components
Alessandro100 40cc089
feed navigation controls
Alessandro100 b4443fc
lint
Alessandro100 c88e23e
copilot pr comments
Alessandro100 a92f684
lighthouse pr throttle
Alessandro100 7e53f25
revert lighthouse settings
Alessandro100 168422e
update feeds promo number to 6000
Alessandro100 3e6a91a
updaate number of countries
Alessandro100 a0314e6
updated number count
Alessandro100 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file was deleted.
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,21 @@ | ||
| { | ||
| "name": "Mobility Database", | ||
| "short_name": "MobilityDB", | ||
| "description": "Access GTFS, GTFS Realtime, GBFS transit data with over 4,000 feeds from 70+ countries.", | ||
| "icons": [ | ||
| { | ||
| "src": "/android-chrome-192x192.png", | ||
| "sizes": "192x192", | ||
| "type": "image/png" | ||
| }, | ||
| { | ||
| "src": "/android-chrome-512x512.png", | ||
| "sizes": "512x512", | ||
| "type": "image/png" | ||
| } | ||
| ], | ||
| "theme_color": "#3959fa", | ||
| "background_color": "#ffffff", | ||
| "display": "standalone", | ||
| "start_url": "/" | ||
| } | ||
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
61 changes: 61 additions & 0 deletions
61
src/app/[locale]/feeds/[feedDataType]/[feedId]/lib/FeedJsonLd.tsx
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,61 @@ | ||
| import { type ReactElement } from 'react'; | ||
| import { getTranslations } from 'next-intl/server'; | ||
| import type { | ||
| AllFeedType, | ||
| GTFSFeedType, | ||
| GTFSRTFeedType, | ||
| } from '../../../../../services/feeds/utils'; | ||
| import { | ||
| formatProvidersSorted, | ||
| generateDescriptionMetaTag, | ||
| } from '../../../../../screens/Feed/Feed.functions'; | ||
| import generateFeedStructuredData from './generate-feed-metadata'; | ||
|
|
||
| interface FeedJsonLdProps { | ||
| feed: AllFeedType; | ||
| relatedFeeds?: AllFeedType[]; | ||
| relatedGtfsRtFeeds?: GTFSRTFeedType[]; | ||
| } | ||
|
|
||
| /** | ||
| * Server component that renders JSON-LD structured data for SEO. | ||
| * Injects a <script type="application/ld+json"> tag directly into the page, | ||
| * following the Next.js App Router recommendation: | ||
| * https://nextjs.org/docs/app/guides/json-ld | ||
| */ | ||
| export default async function FeedJsonLd({ | ||
| feed, | ||
| relatedFeeds, | ||
| relatedGtfsRtFeeds, | ||
| }: FeedJsonLdProps): Promise<ReactElement | null> { | ||
| if (feed == null) return null; | ||
|
|
||
| const t = await getTranslations(); | ||
|
|
||
| const sortedProviders = formatProvidersSorted(feed?.provider ?? ''); | ||
| const feedDataType = feed.data_type; | ||
| const description = generateDescriptionMetaTag( | ||
| t, | ||
| sortedProviders, | ||
| feedDataType as 'gtfs' | 'gtfs_rt' | 'gbfs', | ||
| (feed as { feed_name?: string })?.feed_name, | ||
| ); | ||
|
|
||
| const structuredData = generateFeedStructuredData( | ||
| feed, | ||
| description, | ||
| relatedFeeds, | ||
| relatedGtfsRtFeeds as GTFSFeedType[], | ||
|
Alessandro100 marked this conversation as resolved.
Outdated
|
||
| ); | ||
|
|
||
| if (structuredData == null) return null; | ||
|
|
||
| return ( | ||
| <script | ||
| type='application/ld+json' | ||
| dangerouslySetInnerHTML={{ | ||
| __html: JSON.stringify(structuredData).replace(/</g, '\\u003c'), | ||
| }} | ||
| /> | ||
| ); | ||
| } | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to update these numbers to 6000 feeds and 99 countries ;-)