Skip to content

Commit e008423

Browse files
authored
Merge branch 'main' into feat/dotenv-Implement
2 parents 5e2f9b1 + bb88390 commit e008423

Some content is hidden

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

58 files changed

+943
-588
lines changed

.github/workflows/links.yml

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Link Checker
2+
3+
on:
4+
repository_dispatch:
5+
workflow_dispatch:
6+
schedule:
7+
- cron: '0 0 1 * *' # Run at midnight on the first of every month
8+
9+
jobs:
10+
linkChecker:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout Repository
14+
uses: actions/checkout@v4
15+
16+
- name: Submodule
17+
run: git submodule update --init --recursive
18+
19+
- name: Set up Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20'
23+
24+
- name: Install Dependencies
25+
run: yarn install --frozen-lockfile
26+
27+
- name: Serve App Locally
28+
run: yarn run dev &
29+
30+
- name: Wait for App to Start
31+
run: sleep 20
32+
33+
# This will restore the lychee cache
34+
- name: Restore lychee cache
35+
uses: actions/cache@v4
36+
with:
37+
path: .lycheecache
38+
key: cache-lychee-${{ github.sha }}
39+
restore-keys: cache-lychee-
40+
41+
# This will run the link checker on all markdown files in the pages directory
42+
- name: Link Checker
43+
id: lychee
44+
uses: lycheeverse/lychee-action@v1
45+
with:
46+
args: --base http://localhost:3000 --verbose --no-progress --accept 200,204,429,403 './pages/**/*.md' --cache --max-cache-age 1d http://localhost:3000
47+
token: ${{secrets.AUTH_TOKEN}}
48+
49+
- name: Install Octokit
50+
run: yarn add @octokit/[email protected]
51+
52+
# This will create an issue with the link checker report if it does not exist, otherwise it will update the existing issue.
53+
54+
- name: Create Issue
55+
if: env.lychee_exit_code != 0
56+
uses: actions/github-script@v7
57+
env:
58+
AUTH_TOKEN: ${{secrets.AUTH_TOKEN}}
59+
with:
60+
script: |
61+
const { Octokit } = require("@octokit/core");
62+
const octokit = new Octokit({ auth: process.env.AUTH_TOKEN });
63+
const allIssues = await octokit.request('GET /repos/{owner}/{repo}/issues', {
64+
owner: context.repo.owner,
65+
repo: context.repo.repo
66+
});
67+
68+
const existingIssue = allIssues.data.find(issue => issue.title === 'Link Checker Report');
69+
if (existingIssue) {
70+
await octokit.request('PATCH /repos/{owner}/{repo}/issues/{issue_number}', {
71+
owner: context.repo.owner,
72+
repo: context.repo.repo,
73+
issue_number: existingIssue.number,
74+
body: '## Link Checker Report\n\n' + require('fs').readFileSync('./lychee/out.md', 'utf8')
75+
});
76+
} else {
77+
await octokit.request('POST /repos/{owner}/{repo}/issues', {
78+
owner: context.repo.owner,
79+
repo: context.repo.repo,
80+
title: 'Link Checker Report',
81+
body: '## Link Checker Report\n\n' + require('fs').readFileSync('./lychee/out.md', 'utf8')
82+
});
83+
}

.github/workflows/pr-dependencies.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Check PR Dependencies
2+
3+
on: pull_request
4+
5+
jobs:
6+
check_dependencies:
7+
runs-on: ubuntu-latest
8+
name: Check Dependencies
9+
steps:
10+
- uses: gregsdennis/dependencies-action@main
11+
env:
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CONTRIBUTING.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ If you would like to contribute with designs, we encourage you to join `#design`
7272

7373
We welcome pull requests for editorial suggestions and resolving open issues.
7474

75-
If the pull request would solve a particular issue, reference the issue in the pull request description using a [supported descriptor](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) that will automatically close that issue.
75+
If your pull request addresses a specific issue, please reference this issue in your pull request description using a [supported descriptor](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword). This helps automatically link and close the issue when the pull request is merged.
76+
77+
We strongly encourage linking every pull request to an existing issue. If no corresponding issue exists, please create one first. This allows the community to discuss the required changes. If you are addressing an existing issue, ensure the scope is clear and consider the following:
78+
79+
- If the issue is several years old, verify its relevance by asking in the comments.
80+
- Ensure the discussion within the issue has led to a clear, actionable decision.
7681

7782
Generally, pull requests should be made to the `main` branch.
7883

components/DocsHelp.tsx

+29-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import { useRouter } from 'next/router';
22
import React, { FormEvent, useRef, useState } from 'react';
33

4-
export function DocsHelp() {
4+
interface DocsHelpProps {
5+
markdownFile?: string;
6+
}
7+
8+
export function DocsHelp({ markdownFile }: DocsHelpProps) {
59
const router = useRouter();
10+
const path = encodeURIComponent(router.pathname);
611
const [isFormOpen, setIsFormOpen] = useState(false);
712
const [feedbackStatus, setFeedbackStatus] = useState('');
813
const [isSubmitting, setIsSubmitting] = useState(false);
@@ -214,7 +219,27 @@ export function DocsHelp() {
214219

215220
{feedbackStatus === 'feedback' && (
216221
<div className='my-6 text-[14px]'>
217-
<p>Thank you! We received your feedback.</p>
222+
<p>
223+
Thanks for the feedback! Feel free to join the&nbsp;
224+
<a
225+
target='_blank'
226+
rel='noreferrer'
227+
className='underline'
228+
href='https://json-schema.slack.com/archives/C8C4UBXDF'
229+
>
230+
#website
231+
</a>
232+
&nbsp;channel on&nbsp;
233+
<a
234+
target='_blank'
235+
rel='noreferrer'
236+
className='underline'
237+
href='https://json-schema.org/slack'
238+
>
239+
Slack&nbsp;
240+
</a>
241+
for further discussion.
242+
</p>
218243
</div>
219244
)}
220245

@@ -250,7 +275,7 @@ export function DocsHelp() {
250275
target='_blank'
251276
rel='noreferrer'
252277
className='px-[16px] py-[8px] cursor-pointer border-solid border-[#aaaaaa] border rounded-md hover:bg-gray-200 dark:hover:bg-gray-600'
253-
href='https://github.com/orgs/json-schema-org/projects/16'
278+
href={`https://github.com/json-schema-org/website/blob/main/pages${markdownFile ? (markdownFile === '_indexPage' ? router.asPath + '/_index.md' : router.asPath + '.md') : `/${path}/index.page.tsx`}`}
254279
>
255280
<svg
256281
className='inline-block select-none align-text-bottom mr-1'
@@ -263,7 +288,7 @@ export function DocsHelp() {
263288
>
264289
<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' />
265290
</svg>
266-
Make a contribution
291+
Edit this page on Github
267292
</a>
268293
</div>
269294
<div className='my-2 text-[14px]'>

components/Headlines.tsx

+26-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useState, useEffect } from 'react';
22
import classnames from 'classnames';
33
import slugifyMarkdownHeadline from '~/lib/slugifyMarkdownHeadline';
44
import { useRouter } from 'next/router';
@@ -40,33 +40,46 @@ const Headline = ({
4040
attributes?: Record<string, any>;
4141
}) => {
4242
const router = useRouter();
43+
const [isActive, setIsActive] = useState<boolean>(false);
4344
const asPath = router.asPath;
4445
const slug = slugifyMarkdownHeadline(children as any[]);
4546

47+
useEffect(() => {
48+
const hashIndex = asPath.indexOf('#');
49+
const slugFromPath = hashIndex !== -1 ? asPath.slice(hashIndex + 1) : null;
50+
51+
setIsActive(slug === slugFromPath);
52+
}, [router.asPath]);
53+
54+
const handleHeadingClick = () => {
55+
const url = new URL(asPath, HOST);
56+
const newHash = `#${slug}`;
57+
url.hash = newHash;
58+
59+
const urlString = url.toString().substr(HOST.length, Infinity);
60+
router.push(urlString, undefined, { shallow: true });
61+
setIsActive(true);
62+
};
63+
4664
const attributes = {
4765
...propAttributes,
4866
id: propAttributes?.slug || slug,
4967
className: classnames(
5068
'group cursor-pointer hover:underline',
69+
{ 'text-startBlue dark:text-endBlue': isActive },
5170
propAttributes?.className,
5271
),
53-
onClick: () => {
54-
const url = new URL(asPath, HOST);
55-
// recalculation necessary because of scope issue
56-
const slug = slugifyMarkdownHeadline(children as any[]);
57-
url.hash = `#${slug}`;
58-
59-
const urlString = url.toString().substr(HOST.length, Infinity);
60-
window.location.href = urlString;
61-
},
72+
onClick: handleHeadingClick,
6273
};
6374
const childredWithoutFragment = filterFragment(children);
6475
return (
6576
<Tag attributes={attributes}>
6677
{childredWithoutFragment}
67-
<span className='text-slate-300 inline-block ml-2 opacity-0 group-hover:opacity-100'>
68-
69-
</span>
78+
{isActive && (
79+
<span className={'text-startBlue dark:text-endBlue inline-block ml-2'}>
80+
81+
</span>
82+
)}
7083
</Tag>
7184
);
7285
};

0 commit comments

Comments
 (0)