-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat: add AI Coding Assistants Policy link to footer #8179
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
base: main
Are you sure you want to change the base?
Changes from all commits
c95a6ef
fd0be54
95644c7
c4bb434
06d6ed8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { writeFile, mkdir } from 'fs/promises'; | ||
|
Check failure on line 1 in src/utilities/fetch-footer.mjs
|
||
| import path from 'path'; | ||
|
Check failure on line 2 in src/utilities/fetch-footer.mjs
|
||
|
|
||
| const ARTWORK_README_URL = | ||
| 'https://raw.githubusercontent.com/openjs-foundation/artwork/main/README.md'; | ||
| const OUTPUT_PATH = path.resolve( | ||
| 'src/components/Footer/_footer-legal.json' | ||
| ); | ||
|
|
||
| async function fetchFooter() { | ||
| console.log('Fetching OpenJS Foundation footer template...'); | ||
|
|
||
| const response = await fetch(ARTWORK_README_URL); | ||
| if (!response.ok) { | ||
| throw new Error(`Failed to fetch artwork README: ${response.status}`); | ||
| } | ||
| const readme = await response.text(); | ||
|
|
||
| // Extract the HTML block under "### HTML" | ||
| const htmlSectionMatch = readme.match( | ||
| /### HTML\s*\n+```html\s*\n([\s\S]*?)\n```/ | ||
| ); | ||
|
|
||
| if (!htmlSectionMatch) { | ||
| throw new Error( | ||
| 'Could not find HTML footer template in artwork README' | ||
| ); | ||
| } | ||
|
|
||
| const html = htmlSectionMatch[1].trim(); | ||
|
|
||
| // Parse links from the footer HTML | ||
| const linkRegex = /<a\s+href="([^"]+)">([^<]+)<\/a>/g; | ||
| const paragraphs = html.split('</p>'); | ||
|
|
||
| // Second paragraph contains the links bar | ||
| const linksSection = paragraphs.length > 1 ? paragraphs[1] : ''; | ||
| const links = []; | ||
| let match; | ||
| while ((match = linkRegex.exec(linksSection)) !== null) { | ||
| links.push({ url: match[1], label: match[2] }); | ||
| } | ||
|
|
||
| const data = { links }; | ||
|
|
||
| await mkdir(path.dirname(OUTPUT_PATH), { recursive: true }); | ||
| await writeFile(OUTPUT_PATH, JSON.stringify(data, null, 2)); | ||
|
|
||
| console.log(`Footer data written to ${OUTPUT_PATH}`); | ||
| console.log(`Found ${links.length} footer links`); | ||
| } | ||
|
|
||
| fetchFooter().catch((err) => { | ||
| console.error('Error fetching footer:', err); | ||
| process.exit(1); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this AI generated code?