Skip to content

Commit bbcffe8

Browse files
Merge branch 'main' into feat/blog-card-enhancements
2 parents 77da065 + 1055c7c commit bbcffe8

File tree

124 files changed

+1476
-524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+1476
-524
lines changed

.eslintrc.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = {
33
es2021: true,
44
node: true,
55
browser: true,
6-
"cypress/globals": true
6+
'cypress/globals': true,
77
},
88
settings: {
99
react: {
@@ -34,7 +34,10 @@ module.exports = {
3434

3535
'react/jsx-curly-spacing': ['error', { when: 'never', children: true }],
3636
indent: ['error', 2, { SwitchCase: 1 }],
37-
'linebreak-style': ['error', process.platform === 'win32' ? 'windows' : 'unix'],
37+
'linebreak-style': [
38+
'error',
39+
process.platform === 'win32' ? 'windows' : 'unix',
40+
],
3841
quotes: ['error', 'single'],
3942

4043
'jsx-quotes': ['error', 'prefer-single'],

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
run: yarn run test:coverage:all
6565

6666
- name: Upload coverage report to Codecov
67-
uses: codecov/codecov-action@v5.1.2
67+
uses: codecov/codecov-action@v5.3.1
6868
with:
6969
token: ${{ secrets.CODECOV_TOKEN }}
7070
name: ${{ env.CODECOV_UNIQUE_NAME }}

components/DocsHelp.tsx

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,34 @@ import React, { FormEvent, useRef, useState } from 'react';
33
import extractPathWithoutFragment from '~/lib/extractPathWithoutFragment';
44

55
interface DocsHelpProps {
6-
markdownFile?: string;
6+
fileRenderType?: '_indexmd' | 'indexmd' | 'tsx' | '_md' | string;
7+
showEditOption?: boolean;
78
}
8-
9-
export function DocsHelp({ markdownFile }: DocsHelpProps) {
9+
export function DocsHelp({
10+
fileRenderType,
11+
showEditOption = true,
12+
}: DocsHelpProps) {
1013
const router = useRouter();
11-
const path = encodeURIComponent(router.pathname);
1214
const [isFormOpen, setIsFormOpen] = useState(false);
1315
const [feedbackStatus, setFeedbackStatus] = useState('');
1416
const [isSubmitting, setIsSubmitting] = useState(false);
1517
const [error, setError] = useState('');
1618
const feedbackFormRef = useRef<HTMLFormElement>(null);
17-
19+
let gitredirect = '';
20+
if (
21+
typeof fileRenderType === 'string' &&
22+
fileRenderType.startsWith('https://')
23+
) {
24+
gitredirect = fileRenderType;
25+
} else if (fileRenderType === 'tsx') {
26+
gitredirect = `https://github.com/json-schema-org/website/blob/main/pages${extractPathWithoutFragment(router.asPath) + '/index.page.tsx'}`;
27+
} else if (fileRenderType === '_indexmd') {
28+
gitredirect = `https://github.com/json-schema-org/website/blob/main/pages${extractPathWithoutFragment(router.asPath) + '/_index.md'}`;
29+
} else if (fileRenderType === 'indexmd') {
30+
gitredirect = `https://github.com/json-schema-org/website/blob/main/pages${extractPathWithoutFragment(router.asPath) + '/index.md'}`;
31+
} else {
32+
gitredirect = `https://github.com/json-schema-org/website/blob/main/pages${extractPathWithoutFragment(router.asPath) + '.md'}`;
33+
}
1834
async function createFeedbackHandler(event: FormEvent) {
1935
event.preventDefault();
2036
const formData = new FormData(feedbackFormRef.current!);
@@ -296,28 +312,30 @@ export function DocsHelp({ markdownFile }: DocsHelpProps) {
296312
type of contribution!
297313
</p>
298314
</div>
299-
<div className='my-4 text-[14px]'>
300-
<a
301-
target='_blank'
302-
rel='noreferrer'
303-
className='px-[16px] py-[8px] cursor-pointer border-solid border-[#aaaaaa] border rounded-md hover:bg-gray-200 dark:hover:bg-gray-600'
304-
href={`https://github.com/json-schema-org/website/blob/main/pages${markdownFile ? (markdownFile === '_indexPage' ? extractPathWithoutFragment(router.asPath) + '/_index.md' : extractPathWithoutFragment(router.asPath) + '.md') : `/${path}/index.page.tsx`}`}
305-
data-test='edit-on-github-link'
306-
>
307-
<svg
308-
className='inline-block select-none align-text-bottom mr-1'
309-
aria-hidden='true'
310-
role='img'
311-
viewBox='0 0 16 16'
312-
width='16'
313-
height='16'
314-
fill='currentColor'
315+
{showEditOption && (
316+
<div className='my-4 text-[14px]'>
317+
<a
318+
target='_blank'
319+
rel='noreferrer'
320+
className='px-[16px] py-[8px] cursor-pointer border-solid border-[#aaaaaa] border rounded-md hover:bg-gray-200 dark:hover:bg-gray-600'
321+
href={gitredirect} // Ensure gitredirect is defined
322+
data-test='edit-on-github-link'
315323
>
316-
<path d='M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z' />
317-
</svg>
318-
Edit this page on Github
319-
</a>
320-
</div>
324+
<svg
325+
className='inline-block select-none align-text-bottom mr-1'
326+
aria-hidden='true'
327+
role='img'
328+
viewBox='0 0 16 16'
329+
width='16'
330+
height='16'
331+
fill='currentColor'
332+
>
333+
<path d='M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z' />
334+
</svg>
335+
Edit this page on Github
336+
</a>
337+
</div>
338+
)}
321339
<div className='my-2 text-[14px]'>
322340
<a
323341
target='_blank'

components/JsonEditor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ export default function JsonEditor({ initialCode }: { initialCode: string }) {
333333
</div>
334334
</div>
335335
<Editable
336+
className='overflow-x-auto'
336337
data-test='json-editor'
337338
onCopy={(e) => {
338339
e.preventDefault();
@@ -377,7 +378,6 @@ export default function JsonEditor({ initialCode }: { initialCode: string }) {
377378
(jsonPathsWithJsonScope) => jsonPathsWithJsonScope.jsonPath,
378379
)
379380
.includes(leaf.syntaxPart?.parentJsonPath);
380-
// console.log('jsonPathsWithJsonScope', jsonPathsWithJsonScope, leaf, leaf.syntaxPart?.parentJsonPath)
381381
if (
382382
isJsonScope &&
383383
jsonSchemaReferences.objectProperty[leaf.text]
@@ -424,7 +424,7 @@ export default function JsonEditor({ initialCode }: { initialCode: string }) {
424424
if (!link) return;
425425
router.push(link);
426426
}}
427-
className={classnames('pb-2', textStyles)}
427+
className={classnames('pb-2', textStyles, 'whitespace-pre')}
428428
title={leaf.syntaxPart?.type}
429429
{...attributes}
430430
>

components/Sidebar.tsx

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,31 +269,59 @@ export const DocsNav = ({
269269
});
270270
useEffect(() => {
271271
const pathWtihoutFragment = extractPathWithoutFragment(router.asPath);
272+
const newActive = {
273+
getDocs: false,
274+
getStarted: false,
275+
getReference: false,
276+
getSpecification: false,
277+
};
272278
if (getDocsPath.includes(pathWtihoutFragment)) {
273-
setActive({ ...active, getDocs: true });
279+
newActive.getDocs = true;
274280
} else if (getStartedPath.includes(pathWtihoutFragment)) {
275-
setActive({ ...active, getStarted: true });
281+
newActive.getStarted = true;
276282
} else if (getReferencePath.includes(pathWtihoutFragment)) {
277-
setActive({ ...active, getReference: true });
283+
newActive.getReference = true;
278284
} else if (getSpecificationPath.includes(pathWtihoutFragment)) {
279-
setActive({ ...active, getSpecification: true });
285+
newActive.getSpecification = true;
280286
}
287+
288+
setActive(newActive);
281289
}, [router.asPath]);
282290

283291
const handleClickDoc = () => {
284-
setActive({ ...active, getDocs: !active.getDocs });
292+
setActive({
293+
getDocs: !active.getDocs,
294+
getStarted: false,
295+
getReference: false,
296+
getSpecification: false,
297+
});
285298
};
286299

287300
const handleClickGet = () => {
288-
setActive({ ...active, getStarted: !active.getStarted });
301+
setActive({
302+
getDocs: false,
303+
getStarted: !active.getStarted,
304+
getReference: false,
305+
getSpecification: false,
306+
});
289307
};
290308

291309
const handleClickReference = () => {
292-
setActive({ ...active, getReference: !active.getReference });
310+
setActive({
311+
getDocs: false,
312+
getStarted: false,
313+
getReference: !active.getReference,
314+
getSpecification: false,
315+
});
293316
};
294317

295318
const handleClickSpec = () => {
296-
setActive({ ...active, getSpecification: !active.getSpecification });
319+
setActive({
320+
getDocs: false,
321+
getStarted: false,
322+
getReference: false,
323+
getSpecification: !active.getSpecification,
324+
});
297325
};
298326

299327
const rotate = active.getDocs ? 'rotate(180deg)' : 'rotate(0)';
@@ -392,7 +420,11 @@ export const DocsNav = ({
392420
setOpen={setOpen}
393421
/>
394422
<DocLink uri='/overview/faq' label='FAQ' setOpen={setOpen} />
395-
<DocLink uri='/pro-help' label='Pro Help' setOpen={setOpen} />
423+
<DocLink
424+
uri='/overview/pro-help'
425+
label='Pro Help'
426+
setOpen={setOpen}
427+
/>
396428
<DocLink
397429
uri='/overview/similar-technologies'
398430
label='Similar Technologies'
@@ -736,7 +768,7 @@ export const DocsNav = ({
736768
'transition-all duration-500 ease-in-out',
737769
{
738770
'max-h-0 opacity-0 overflow-hidden': !active.getSpecification,
739-
'max-h-80 opacity-100': active.getSpecification,
771+
'max-h-80 opacity-100 overflow-hidden': active.getSpecification,
740772
},
741773
)}
742774
id='specification'

components/StyledMarkdown.tsx

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ const StyledMarkdownBlock = ({ markdown }: { markdown: string }) => {
166166
<FullMarkdownContext.Provider value={markdown}>
167167
<Markdown
168168
options={{
169+
forceBlock: true,
169170
overrides: {
170171
h1: { component: Headline1 },
171172
h2: { component: Headline2 },
@@ -307,34 +308,25 @@ const StyledMarkdownBlock = ({ markdown }: { markdown: string }) => {
307308
}
308309

309310
return (
310-
<div className='overflow-x-auto flex-basis-0 max-w-full min-w-0 shrink lg:max-w-[800px] xl:max-w-[900px]'>
311-
{/* definitely not the best way to prevent overflowing. found no better way that worked */}
311+
<div className='overflow-x-auto rounded-lg bg-gray-800 text-white'>
312312
<Highlight
313313
language={language}
314-
wrapLines={true}
315-
wrapLongLines={true}
316-
customStyle={{
317-
borderRadius: 10,
318-
paddingTop: 15,
319-
paddingBottom: 10,
320-
paddingLeft: 10,
321-
marginBottom: 20,
322-
maxWidth: '100%',
323-
}}
324-
lineNumberStyle={{
325-
marginRight: 10,
326-
}}
327314
style={atomOneDark}
328315
showLineNumbers
329-
startingLineNumber={1}
330-
lineProps={() => {
331-
const isHighlighted = false;
332-
return {
333-
className: `${isHighlighted ? 'bg-code-editor-dark-highlight block ml-10 w-full' : ''} pr-8`,
334-
};
316+
lineNumberStyle={{
317+
color: '#64748B',
318+
fontSize: '16px',
319+
paddingRight: '10px',
320+
}}
321+
customStyle={{
322+
padding: '12px',
323+
fontFamily: 'monospace',
324+
fontSize: '16px',
335325
}}
336326
codeTagProps={{
337-
className: 'mr-8',
327+
style: {
328+
fontFamily: 'monospace',
329+
},
338330
}}
339331
>
340332
{code}

0 commit comments

Comments
 (0)