-
-
Notifications
You must be signed in to change notification settings - Fork 656
add: structured data for profile pages to improve visibility #1953
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
arkid15r
merged 13 commits into
OWASP:main
from
bandhan-majumder:feature/profile-visibility
Aug 6, 2025
Merged
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
189b00b
add: structured data for profile pages to improve visibility
bandhan-majumder c6ad94b
Merge branch 'main' into feature/profile-visibility
bandhan-majumder 1e6e67e
Update structuredData.ts
bandhan-majumder ab752f7
Update StructuredDataScript.tsx
bandhan-majumder ce7b33f
Merge branch 'main' into feature/profile-visibility
bandhan-majumder d61352f
Merge branch 'main' into feature/profile-visibility
bandhan-majumder c75f0c0
Merge branch 'main' into feature/profile-visibility
bandhan-majumder 1ecd590
Merge branch 'main' into feature/profile-visibility
kasya bda01d3
add suggestioins and test
bandhan-majumder a517ff9
Merge branch 'main' into feature/profile-visibility
bandhan-majumder a05774f
Update StructuredDataScript.tsx
bandhan-majumder 397547c
Merge branch 'main' into pr/bandhan-majumder/1953
arkid15r 56da376
Update code
arkid15r 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import React from 'react' | ||
| import { ProfilePageStructuredData } from 'types/profilePageStructuredData' | ||
|
|
||
| interface StructuredDataScriptProps { | ||
| data: ProfilePageStructuredData | ||
| } | ||
|
|
||
| // dangerouslySetInnerHTML injects the JSON data as a script tag. | ||
| const StructuredDataScript: React.FC<StructuredDataScriptProps> = ({ data }) => { | ||
| return ( | ||
| <script | ||
| type="application/ld+json" | ||
| dangerouslySetInnerHTML={{ | ||
| __html: JSON.stringify(data, null, 2), // include everything with 2 spaces indentation | ||
| }} | ||
| /> | ||
| ) | ||
| } | ||
|
bandhan-majumder marked this conversation as resolved.
|
||
|
|
||
| export default StructuredDataScript | ||
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,35 @@ | ||
| export interface ProfilePageStructuredData { | ||
| '@context': string | ||
| '@type': string | ||
| mainEntity: { | ||
| '@type': string | ||
| name: string | ||
| description?: string | ||
| image?: string | ||
| url?: string | ||
| sameAs?: string[] | ||
| worksFor?: { | ||
| '@type': string | ||
| name: string | ||
| } | ||
| address?: { | ||
| '@type': string | ||
| addressLocality: string | ||
| } | ||
| knowsAbout?: string[] | ||
| hasOccupation?: { | ||
| '@type': string | ||
| name: string | ||
| } | ||
| memberOf?: { | ||
| '@type': string | ||
| name: string | ||
| url: string | ||
| } | ||
| } | ||
| interactionStatistic?: Array<{ | ||
| '@type': string | ||
| interactionType: string | ||
| userInteractionCount: number | ||
| }> | ||
| } |
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,74 @@ | ||
| import { ProfilePageStructuredData } from 'types/profilePageStructuredData' | ||
| import type { UserDetails } from 'types/user' | ||
|
|
||
| /** | ||
| * JSON-LD structure data for ProfilePage | ||
| * https://developers.google.com/search/docs/appearance/structured-data/profile-page | ||
| * | ||
| * - @context: "https://schema.org" | ||
| * - @type: "ProfilePage" | ||
| * - mainEntity: A Person or Organization (using type Person for OWASP community members) | ||
| * | ||
| */ | ||
| export function generateProfilePageStructuredData( | ||
| user: UserDetails, | ||
| baseUrl = 'https://nest.owasp.org' | ||
| ): ProfilePageStructuredData { | ||
| const profileUrl = `${baseUrl}/members/${user.login}` | ||
|
|
||
| const structuredData: ProfilePageStructuredData = { | ||
| '@context': 'https://schema.org', | ||
| '@type': 'ProfilePage', | ||
| mainEntity: { | ||
| '@type': 'Person', | ||
| name: user.name || user.login, | ||
| description: user.bio, | ||
| image: user.avatarUrl, | ||
| url: profileUrl, | ||
| sameAs: [user.url], // GitHub profile URL | ||
| memberOf: { | ||
| '@type': 'Organization', | ||
| name: 'OWASP', | ||
| url: 'https://owasp.org', | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| if (user.company) { | ||
|
bandhan-majumder marked this conversation as resolved.
Outdated
|
||
| structuredData.mainEntity.worksFor = { | ||
| '@type': 'Organization', | ||
| name: user.company, | ||
| } | ||
| } | ||
|
|
||
| if (user.location) { | ||
| structuredData.mainEntity.address = { | ||
| '@type': 'PostalAddress', | ||
| addressLocality: user.location, | ||
| } | ||
| } | ||
|
|
||
| structuredData.mainEntity.knowsAbout = [ | ||
|
bandhan-majumder marked this conversation as resolved.
Outdated
|
||
| 'Application Security', | ||
| 'OWASP', | ||
| 'Cybersecurity', | ||
| 'Software Security', | ||
| ] | ||
|
|
||
| structuredData.mainEntity.hasOccupation = { | ||
| '@type': 'Occupation', | ||
| name: 'OWASP Community Member', | ||
| } | ||
|
|
||
| if (user.followersCount > 0) { | ||
| structuredData.interactionStatistic = [ | ||
| { | ||
| '@type': 'InteractionCounter', | ||
| interactionType: 'https://schema.org/FollowAction', | ||
| userInteractionCount: user.followersCount, | ||
| }, | ||
| ] | ||
| } | ||
|
|
||
| return structuredData | ||
| } | ||
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.