Skip to content
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

feat: add SEO #198

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: some seo details
  • Loading branch information
ayussh-2 committed Oct 22, 2024
commit a88a5b62a5c955bf4257a39a6edb9760882c9fb2
2 changes: 1 addition & 1 deletion public/robots.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
User-agent: *
Allow: /

Sitemap: https://yourcollege.edu/sitemap.xml
Sitemap: https://innonitrkl.in/sitemap.xml
14 changes: 7 additions & 7 deletions public/sitemap.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://youreventwebsite.com/</loc>
<loc>https://innonitrkl.in/</loc>
<lastmod>2024-10-22</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://youreventwebsite.com/event-details</loc>
<loc>https://innonitrkl.in/events</loc>
<lastmod>2024-10-22</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
<priority>0.9</priority>
</url>
<url>
<loc>https://youreventwebsite.com/schedule</loc>
<loc>https://innonitrkl.in/register</loc>
<lastmod>2024-10-22</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
<priority>0.9</priority>
</url>
<url>
<loc>https://youreventwebsite.com/registration</loc>
<loc>https://innonitrkl.in/refundPolicy</loc>
<lastmod>2024-10-22</lastmod>
<changefreq>weekly</changefreq>
<priority>0.6</priority>
<priority>0.8</priority>
</url>
</urlset>
Binary file removed public/static/images/about_bg.png
Binary file not shown.
Binary file removed public/static/images/ellipse.png
Binary file not shown.
Binary file removed public/static/images/noise&texture.png
Binary file not shown.
Binary file modified src/app/favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion src/app/layout.js
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ const spaceGrotesk = SpaceGrotesk({

export const metadata = {
title: 'Innovision 2024',
description: 'Created by GDSC NIT Rourkela',
description: 'Crafted by GDSC NIT Rourkela',
};

export default function RootLayout({ children }) {
16 changes: 0 additions & 16 deletions src/app/page.js
Original file line number Diff line number Diff line change
@@ -5,26 +5,10 @@ import { AboutUsMain } from '@/components/AboutUs/Main';
import { EventSectionMain } from '@/components/EventsSection/wrapperComponents/Main';
import { StatisticsMain } from '@/components/Statistics/wrapper/Main';
import { SponsorSection } from '@/components/Sponsors/sponsors';
import SEO from '@/components/SEO';
import EventStructuredData from '@/components/EventStructureData';

const Page = () => {
return (
<>
<SEO
title='INNOVISION 2024 | NIT ROURKELA'
description='Join us for the biggest college event of the year! Featuring workshops, competitions, and networking opportunities.'
ogImage='https://yourcollege.edu/event-image.jpg'
ogUrl='https://yourcollege.edu/awesome-event-2024'
/>
<EventStructuredData
name='Awesome College Event 2024'
startDate='2024-09-15T09:00'
endDate='2024-09-17T18:00'
location='Your College Campus'
description='Join us for the biggest college event of the year!'
organizerName='Your College Name'
/>
<Hero />
<AboutUsMain />
<StatisticsMain />
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@ import DetailsCard from '../../CardComponents/DetailsCard/DetailsCard';
import tw, { styled } from 'twin.macro';
import { memo } from 'react';

// Styled components
const DescriptionContainer = styled.div`
${tw`w-full mt-8 mb-20 h-auto relative`};
`;
@@ -12,14 +11,12 @@ const DescriptionSlide = styled(motion.div)`
${tw`w-full`};
`;

// Framer Motion variants outside the component to avoid recalculating
const slideVariants = {
enter: { x: 50, opacity: 0 },
center: { x: 0, opacity: 1 },
exit: { x: -50, opacity: 0 },
};

// Memoized DetailsCard for preventing unnecessary re-renders
const MemoizedDetailsCard = memo(DetailsCard);

const DescriptionCarousel = ({ currentIndex, descriptionItems }) => {
@@ -34,7 +31,6 @@ const DescriptionCarousel = ({ currentIndex, descriptionItems }) => {
exit='exit'
transition={{ duration: 0.5 }}
>
{/* Use memoized DetailsCard */}
<MemoizedDetailsCard {...descriptionItems[currentIndex]} />
</DescriptionSlide>
</AnimatePresence>
23 changes: 13 additions & 10 deletions src/components/EventsPage/index.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
// import DualCarousel from './Carousel/DualCarousel/DualCarousel';
import EventStructuredData from '@/components/SEO/EventStructureData';
import { SliderEventsWrapper } from './Carousel/PreviewCarousel/EventWrapper';
import SEO from '../SEO';

const MainCarousel = ({ previewItems, descriptionItems }) => {
return (
<>
<SEO
title='Awesome College Event 2024 | Your College Name'
description='Join us for the biggest college event of the year! Featuring workshops, competitions, and networking opportunities.'
ogImage='https://yourcollege.edu/event-image.jpg'
ogUrl='https://yourcollege.edu/awesome-event-2024'
/>

{descriptionItems.length !== 0 &&
descriptionItems.map((eventData) => (
<EventStructuredData
description={eventData.Description}
endDate={'2024-11-10T23:59:59+00:00'}
location={eventData.Location}
name={eventData.Heading}
organizerName={'INNOVISION'}
startDate={'2024-11-08T00:00:00+00:00'}
key={eventData.Heading}
/>
))}
<SliderEventsWrapper previewItems={previewItems} descriptionItems={descriptionItems} />
</>
);
1 change: 0 additions & 1 deletion src/components/EventsSection/wrapperComponents/Main.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Header } from '../Header.jsx/header';
import { SubHeader } from '../Header.jsx/SubHeader';
import { Body } from './Body';

export const EventSectionMain = () => {
196 changes: 196 additions & 0 deletions src/components/SEO/Checker.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
'use client';
import React, { useEffect, useState } from 'react';
import { Check, X, AlertCircle, ChevronDown, ChevronUp } from 'lucide-react';

const SEOChecker = () => {
const [seoResults, setSeoResults] = useState({
title: { present: false, content: '' },
description: { present: false, content: '' },
ogTags: {
present: false,
title: '',
description: '',
image: '',
url: '',
},
structuredData: { present: false, content: '' },
});
const [expandedSections, setExpandedSections] = useState({});

useEffect(() => {
checkSEO();
}, []);

const checkSEO = () => {
// Check title
const title = document.title;

// Check meta description
const description = document.querySelector('meta[name="description"]')?.content;

// Check OG tags
const ogTitle = document.querySelector('meta[property="og:title"]')?.content;
const ogDescription = document.querySelector('meta[property="og:description"]')?.content;
const ogImage = document.querySelector('meta[property="og:image"]')?.content;
const ogUrl = document.querySelector('meta[property="og:url"]')?.content;

// Check structured data
const structuredData = document.querySelector(
'script[type="application/ld+json"]',
)?.textContent;

setSeoResults({
title: {
present: !!title,
content: title || '',
},
description: {
present: !!description,
content: description || '',
},
ogTags: {
present: !!(ogTitle && ogDescription && ogImage && ogUrl),
title: ogTitle || '',
description: ogDescription || '',
image: ogImage || '',
url: ogUrl || '',
},
structuredData: {
present: !!structuredData,
content: structuredData || '',
},
});
};

const toggleSection = (section) => {
setExpandedSections((prev) => ({
...prev,
[section]: !prev[section],
}));
};

const renderContent = (section, content) => {
if (!expandedSections[section]) return null;
return (
<div className='mt-2 p-3 bg-gray-100 rounded-md text-sm overflow-auto'>
<pre className='whitespace-pre-wrap break-words'>
{typeof content === 'string' ? content : JSON.stringify(content, null, 2)}
</pre>
</div>
);
};

return (
<div className='max-w-2xl mx-auto my-8 p-6 bg-white rounded-lg shadow-lg'>
<div className='flex items-center gap-2 mb-6'>
<AlertCircle className='w-5 h-5 text-blue-500' />
<h2 className='text-xl font-bold'>SEO Check Results</h2>
</div>

<div className='space-y-4'>
<div className='border rounded-md'>
<div
className='flex items-center justify-between p-3 cursor-pointer hover:bg-gray-50'
onClick={() => toggleSection('title')}
>
<span className='font-medium'>Page Title</span>
<div className='flex items-center gap-2'>
{seoResults.title.present ? (
<Check className='w-5 h-5 text-green-500' />
) : (
<X className='w-5 h-5 text-red-500' />
)}
{expandedSections.title ? (
<ChevronUp className='w-4 h-4' />
) : (
<ChevronDown className='w-4 h-4' />
)}
</div>
</div>
{renderContent('title', seoResults.title.content)}
</div>

<div className='border rounded-md'>
<div
className='flex items-center justify-between p-3 cursor-pointer hover:bg-gray-50'
onClick={() => toggleSection('description')}
>
<span className='font-medium'>Meta Description</span>
<div className='flex items-center gap-2'>
{seoResults.description.present ? (
<Check className='w-5 h-5 text-green-500' />
) : (
<X className='w-5 h-5 text-red-500' />
)}
{expandedSections.description ? (
<ChevronUp className='w-4 h-4' />
) : (
<ChevronDown className='w-4 h-4' />
)}
</div>
</div>
{renderContent('description', seoResults.description.content)}
</div>

<div className='border rounded-md'>
<div
className='flex items-center justify-between p-3 cursor-pointer hover:bg-gray-50'
onClick={() => toggleSection('ogTags')}
>
<span className='font-medium'>Open Graph Tags</span>
<div className='flex items-center gap-2'>
{seoResults.ogTags.present ? (
<Check className='w-5 h-5 text-green-500' />
) : (
<X className='w-5 h-5 text-red-500' />
)}
{expandedSections.ogTags ? (
<ChevronUp className='w-4 h-4' />
) : (
<ChevronDown className='w-4 h-4' />
)}
</div>
</div>
{renderContent('ogTags', {
title: seoResults.ogTags.title,
description: seoResults.ogTags.description,
image: seoResults.ogTags.image,
url: seoResults.ogTags.url,
})}
</div>

<div className='border rounded-md'>
<div
className='flex items-center justify-between p-3 cursor-pointer hover:bg-gray-50'
onClick={() => toggleSection('structuredData')}
>
<span className='font-medium'>Structured Data</span>
<div className='flex items-center gap-2'>
{seoResults.structuredData.present ? (
<Check className='w-5 h-5 text-green-500' />
) : (
<X className='w-5 h-5 text-red-500' />
)}
{expandedSections.structuredData ? (
<ChevronUp className='w-4 h-4' />
) : (
<ChevronDown className='w-4 h-4' />
)}
</div>
</div>
{renderContent('structuredData', seoResults.structuredData.content)}
</div>

{!Object.values(seoResults).every((item) => item.present) && (
<div className='mt-6 p-4 bg-yellow-50 text-yellow-800 rounded-md'>
<p className='text-sm'>
Some SEO elements are missing. Click on each section to view details.
</p>
</div>
)}
</div>
</div>
);
};

export default SEOChecker;
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions src/components/shared/HOC/Hoc.jsx
Original file line number Diff line number Diff line change
@@ -2,10 +2,17 @@
import { AuthProvider } from '@/context/auth-context';
import { Footer } from '../../Marginals/Footer/Footer';
import Navbar from '../../Marginals/navbar/navbar';
import SEO from '@/components/SEO/SEO';

function Hoc({ children }) {
return (
<AuthProvider>
<SEO
title='INNOVISION 2024 | NIT ROURKELA'
description='Join us for the biggest college event of the year! Featuring workshops, competitions, and networking opportunities.'
ogImage='https://innonitrkl.in/'
ogUrl='https://innonitrkl.in/'
/>
<Navbar />
<div>{children}</div>
<Footer />
2 changes: 1 addition & 1 deletion src/config/content/Footer.js
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ export const secondcol = [
export const thirdcol = [
{
id: 1,
title: 'Event Brouchere',
title: 'Event Brochure',
url: 'https://drive.google.com/file/d/1jWXT8ShzBW5KTn50DrTsgSqLgmSJMwTO/view?usp=sharing',
},
{