Add json-ld schema to the roadmap pages

pull/3296/head
Kamran Ahmed 2 years ago
parent 6922fd826f
commit 6b52baf093
  1. 11
      src/components/FAQs/FAQs.astro
  2. 2
      src/components/MarkdownRoadmap.astro
  3. 6
      src/layouts/BaseLayout.astro
  4. 20
      src/lib/jsonld-schema.ts
  5. 8
      src/pages/[...topicId].astro
  6. 17
      src/pages/[roadmapId]/index.astro
  7. 144
      src/roadmaps/frontend/faqs.astro

@ -1,9 +1,14 @@
---
export type FAQType = {
question: string;
answer: string[];
};
---
<div class='border-t bg-gray-100'>
<div class='container'>
<div class='flex justify-between relative -top-5'>
<h1 class='text-sm sm:text-base font-medium py-1 px-3 border bg-white rounded-md'>
Frequently Asked Questions
</h1>
<h1 class='text-sm sm:text-base font-medium py-1 px-3 border bg-white rounded-md'>Frequently Asked Questions</h1>
</div>
<div class='flex flex-col gap-1 pb-8'>

@ -10,7 +10,7 @@ export interface Props {
const { roadmapId, description } = Astro.props;
---
<div class='bg-gray-50 py-4 sm:py-10'>
<div class='bg-gray-50 py-2'>
<div
class='container prose prose-headings:mt-4 prose-headings:mb-2 prose-p:mb-0.5 relative prose-code:text-white'
>

@ -16,7 +16,7 @@ export interface Props {
noIndex?: boolean;
permalink?: string;
sponsor?: SponsorType;
jsonLd?: Record<string, unknown>;
jsonLd?: Record<string, unknown>[];
}
const {
@ -26,7 +26,7 @@ const {
noIndex = false,
permalink = '',
sponsor,
jsonLd,
jsonLd = [],
} = Astro.props;
// Remove trailing slashes to consider the page as canonical
@ -85,7 +85,7 @@ const commitUrl = `https://github.com/kamranahmedse/developer-roadmap/commit/${i
<link rel='icon' href='/manifest/favicon.ico' type='image/x-icon' />
<slot name='after-header' />
{jsonLd && <script type='application/ld+json' set:html={JSON.stringify(jsonLd)} />}
{jsonLd.length > 0 && <script type='application/ld+json' set:html={JSON.stringify(jsonLd)} />}
</head>
<body>
<YouTubeBanner />

@ -1,3 +1,5 @@
import type { FAQType } from '../components/FAQs/FAQs.astro';
type ArticleSchemaProps = {
url: string;
headline: string;
@ -8,8 +10,7 @@ type ArticleSchemaProps = {
};
export function generateArticleSchema(article: ArticleSchemaProps) {
const { url, headline, description, imageUrl, datePublished, dateModified } =
article;
const { url, headline, description, imageUrl, datePublished, dateModified } = article;
return {
'@context': 'https://schema.org',
@ -38,3 +39,18 @@ export function generateArticleSchema(article: ArticleSchemaProps) {
dateModified: dateModified,
};
}
export function generateFAQSchema(faqs: FAQType[]) {
return {
'@context': 'https://schema.org',
'@type': 'FAQPage',
mainEntity: faqs.map((faq) => ({
'@type': 'Question',
name: faq.question,
acceptedAnswer: {
'@type': 'Answer',
text: faq.answer,
},
})),
};
}

@ -3,7 +3,6 @@ import Breadcrumbs from '../components/Breadcrumbs.astro';
import RoadmapBanner from '../components/RoadmapBanner.astro';
import BaseLayout from '../layouts/BaseLayout.astro';
import { getTopicFiles, TopicFileType } from '../lib/topic';
import '../styles/prism.css';
export async function getStaticPaths() {
const topicPathMapping = await getTopicFiles();
@ -15,8 +14,7 @@ export async function getStaticPaths() {
}
const { topicId } = Astro.params;
const { file, breadcrumbs, roadmapId, roadmap, heading } =
Astro.props as TopicFileType;
const { file, breadcrumbs, roadmapId, roadmap, heading } = Astro.props as TopicFileType;
---
<BaseLayout
@ -29,9 +27,7 @@ const { file, breadcrumbs, roadmapId, roadmap, heading } =
<div class='bg-gray-50'>
<Breadcrumbs breadcrumbs={breadcrumbs} roadmapId={roadmapId} />
<div
class='container pb-16 prose prose-p:mt-0 prose-h1:mb-4 prose-h2:mb-3 prose-h2:mt-0'
>
<div class='container pb-16 prose prose-p:mt-0 prose-h1:mb-4 prose-h2:mb-3 prose-h2:mt-0'>
<main id='main-content'>
<file.Content />
</main>

@ -5,7 +5,7 @@ import MarkdownRoadmap from '../../components/MarkdownRoadmap.astro';
import RoadmapHeader from '../../components/RoadmapHeader.astro';
import UpcomingRoadmap from '../../components/UpcomingRoadmap.astro';
import BaseLayout from '../../layouts/BaseLayout.astro';
import { generateArticleSchema } from '../../lib/jsonld-schema';
import { generateArticleSchema, generateFAQSchema } from '../../lib/jsonld-schema';
import { getRoadmapIds, RoadmapFrontmatter } from '../../lib/roadmap';
export async function getStaticPaths() {
@ -25,17 +25,24 @@ const roadmapFile = await import(`../../roadmaps/${roadmapId}/${roadmapId}.md`);
const questions = await import(`../../roadmaps/${roadmapId}/faqs.astro`);
const roadmapData = roadmapFile.frontmatter as RoadmapFrontmatter;
let articleSchema;
let jsonLdSchema = [];
if (roadmapData.schema) {
const roadmapSchema = roadmapData.schema;
articleSchema = generateArticleSchema({
jsonLdSchema.push(
generateArticleSchema({
url: `https://roadmap.sh/${roadmapId}`,
headline: roadmapSchema.headline,
description: roadmapSchema.description,
datePublished: roadmapSchema.datePublished,
dateModified: roadmapSchema.dateModified,
imageUrl: roadmapSchema.imageUrl,
});
})
);
}
if (questions.faqs) {
jsonLdSchema.push(generateFAQSchema(questions.faqs));
}
---
@ -46,7 +53,7 @@ if (roadmapData.schema) {
keywords={roadmapData.seo.keywords}
sponsor={roadmapData.sponsor}
noIndex={roadmapData.isUpcoming}
jsonLd={articleSchema}
jsonLd={jsonLdSchema}
>
<RoadmapHeader
description={roadmapData.description}

@ -1,100 +1,64 @@
---
import Answer from '../../components/FAQs/Answer.astro';
import FAQs from '../../components/FAQs/FAQs.astro';
import FAQs, { FAQType } from '../../components/FAQs/FAQs.astro';
import Question from '../../components/FAQs/Question.astro';
export const faqs: FAQType[] = [
{
question: 'What is Frontend Development?',
answer: [
"Front-end development is the devleopment of visual and interactive elements of a website that users interact with directly. It's a combination of HTML, CSS and JavaScript, where HTML provides the structure, CSS the styling and layout, and JavaScript the dynamic behaviour and interactivity.",
"As a front-end developer, you'll be responsible for creating the user interface of a website, to ensure it looks good and is easy to use, with great focus on design principles and user experience. You'll be working closely with designers, back-end developers, and project managers to make sure the final product meets the client's needs and provides the best possible experience for the end-users.",
],
},
{
question: 'What are the job titles of a Frontend Developer?',
answer: [
'Front-end developers are also known as front-end engineers, front-end web developers, JavaScript Developers, HTML/CSS Developer, front-end web designers, and front-end web architects.',
"Each of these roles mostly encompass the same front-end development skills but require different levels of expertise in different front-end development skills. It's better to look at the job description to get an idea about the job requirements.",
],
},
{
question: 'How to become a Frontend Developer?',
answer: [
"Start with learning HTML and CSS; don't wait to fully master these and start building simple projects as soon as possible. You could try rebuilding the frontend of your favorite websites using HTML and CSS to start with. Do as many of these projects as possible as you keep learning. Once you are somewhat comfortable with HTML and CSS, start learning some basic JavaScript (DOM manipulation, making AJAX calls etc) and learn how to add interactivity to your websites. While you are at it learn some basics of Git and GitHub. At this point you should be able to get an entry level frontend development job. Keep revisiting this roadmap and try to fill the gaps in your knowledge.",
],
},
{
question: 'How long does it take to become a Frontend Developer?',
answer: [
'The amount of time it takes to become a frontend developer can vary depending on several factors, such as your learning pace, previous experience and the amount of time you are able to dedicate to learning.',
"However, to give you a rough idea, if you are a complete beginner, it could take you anywhere from 3 to 6 months to get a job as an entry level frontend developer. If you are already familiar with some of the frontend technologies, it could take you anywhere from 1 to 3 months. What's important is to practice as much you can while you are learning i.e. by building as many projects as you can. You should also participate in online communities and ask for feedback from more experienced developers to accelerate your learning process.",
],
},
{
question: 'What are the Frontend Developer salaries?',
answer: [
'Frontend developer salaries can vary depending on factors such as location, experience, and company size. According to data from Glassdoor, the average base salary for a frontend developer in the United States is around $80,000 per year. However, this number can vary greatly depending on location, with the highest-paying cities such as San Francisco, Seattle, and New York having an average salary of $110,000 to $130,000.',
"It's important to keep in mind that these are just averages, and salaries can vary greatly depending on factors such as experience level, specific skills, and the company you work for. With more experience and specific skills you can expect to earn more.",
'It is worth looking at a range of resources, including salary surveys, and job boards to get a general understanding of the current market in your location and experience level. Also try reaching out to other professionals in the field and getting an understanding of their own experience and salary ranges.',
],
},
{
question: 'Should I learn everything listed on the Frontend Roadmap?',
answer: [
"This roadmap contains everything that you might encounter while working as a Frontend Developer. You may not need everything listed on this roadmap to get into the industry; every job is different and most of the jobs will require a subset of the items on the roadmap. However, knowing what you don't know is as important as knowing things, so you can use this roadmap to get an idea of what you are missing as well.",
"If you are a beginner who is just getting started, don't feel overwhelmed by looking at this roadmap. Look at the answer to the FAQ 'How to become a Frontend Developer?'",
],
},
];
---
<FAQs>
<Question isActive question='What is Frontend Development?'>
<Answer>
<p class='mb-3'>
Front-end development is the devleopment of visual and interactive elements of a website that users interact
with directly. It's a combination of HTML, CSS and JavaScript, where HTML provides the structure, CSS the
styling and layout, and JavaScript the dynamic behaviour and interactivity.
</p>
<p>
As a front-end developer, you'll be responsible for creating the user interface of a website, to ensure it looks
good and is easy to use, with great focus on design principles and user experience. You'll be working closely
with designers, back-end developers, and project managers to make sure the final product meets the client's
needs and provides the best possible experience for the end-users.
</p>
</Answer>
</Question>
<Question question='What are the job titles of a Frontend Developer?'>
<Answer>
<p class='mb-3'>
Front-end developers are also known as front-end engineers, front-end web developers, JavaScript Developers,
HTML/CSS Developer, front-end web designers, and front-end web architects.
</p>
<p>
Each of these roles mostly encompass the same front-end development skills but require different levels of
expertise in different front-end development skills. It's better to look at the job description to get an idea
about the job requirements.
</p>
</Answer>
</Question>
<Question question='How to become a Frontend Developer?'>
<Answer>
<p>
Start with learning HTML and CSS; don't wait to fully master these and start building simple projects as soon as
possible. You could try rebuilding the frontend of your favorite websites using HTML and CSS to start with. Do
as many of these projects as possible as you keep learning. Once you are somewhat comfortable with HTML and CSS,
start learning some basic JavaScript (DOM manipulation, making AJAX calls etc) and learn how to add
interactivity to your websites. While you are at it learn some basics of Git and GitHub. At this point you
should be able to get an entry level frontend development job. Keep revisiting this roadmap and try to fill the
gaps in your knowledge.
</p>
</Answer>
</Question>
<Question question='How long does it take to become a Frontend Developer?'>
<Answer>
<p class='mb-3'>
The amount of time it takes to become a frontend developer can vary depending on several factors, such as your
learning pace, previous experience and the amount of time you are able to dedicate to learning.
</p>
<p class='mb-3'>
However, to give you a rough idea, if you are a complete beginner, it could take you anywhere from 3 to 6 months
to get a job as an entry level frontend developer. If you are already familiar with some of the frontend
technologies, it could take you anywhere from 1 to 3 months. What's important is to practice as much you can
while you are learning i.e. by building as many projects as you can. You should also participate in online
communities and ask for feedback from more experienced developers to accelerate your learning process.
</p>
</Answer>
</Question>
<Question question='What are the Frontend Developer salaries?'>
<Answer>
<p class='mb-3'>
Frontend developer salaries can vary depending on factors such as location, experience, and company size.
According to data from Glassdoor, the average base salary for a frontend developer in the United States is
around $80,000 per year. However, this number can vary greatly depending on location, with the highest-paying
cities such as San Francisco, Seattle, and New York having an average salary of $110,000 to $130,000.
</p>
<p class='mb-3'>
It's important to keep in mind that these are just averages, and salaries can vary greatly depending on factors
such as experience level, specific skills, and the company you work for. With more experience and specific
skills you can expect to earn more.
</p>
<p>
It is worth looking at a range of resources, including salary surveys, and job boards to get a general
understanding of the current market in your location and experience level. Also try reaching out to other
professionals in the field and getting an understanding of their own experience and salary ranges.
</p>
</Answer>
</Question>
<Question question='Should I learn everything listed on the Frontend Roadmap?'>
{
faqs.map((faq, questionIndex) => (
<Question isActive={questionIndex === 0} question={faq.question}>
<Answer>
<p class='mb-3'>
This roadmap contains everything that you might encounter while working as a Frontend Developer. You may not
need everything listed on this roadmap to get into the industry; every job is different and most of the jobs
will require a subset of the items on the roadmap. However, knowing what you don't know is as important as
knowing things, so you can use this roadmap to get an idea of what you are missing as well.
</p>
<p>
If you are a beginner who is just getting started, don't feel overwhelmed by looking at this roadmap. Look at
the answer to the FAQ "How to become a Frontend Developer?"
</p>
{faq.answer.map((answer, index) => (
<p class:list={{ 'mb-3': index !== faq.answer.length - 1 }}>{answer}</p>
))}
</Answer>
</Question>
))
}
</FAQs>

Loading…
Cancel
Save