-
Notifications
You must be signed in to change notification settings - Fork 45
[FTF-426] Post-nav launch fixes #3022
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0567151
fix: add external icon to external nav links
jamiehenson f923380
fix: prevent multiple rerenders of the inkeep popup when using keyboa…
jamiehenson 6c8e13e
chore: remove unused searchbar assets and config
jamiehenson 5dc8733
feat: add markdown view/copy links to pageheader, condense languagese…
jamiehenson a3ee0a1
fix: actually hook up logout button
jamiehenson 085e95d
chore: include intro in generated md for pages
jamiehenson 78afeab
fix: isolate main page body from leftnav scroll-into-view behaviour
jamiehenson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ import { createContentMenuDataFromPage } from './createContentMenuDataFromPage'; | |
| import { DEFAULT_LANGUAGE } from './constants'; | ||
| import { writeRedirectToConfigFile, getRedirectCount } from './writeRedirectToConfigFile'; | ||
| import { siteMetadata } from '../../gatsby-config'; | ||
| import { GatsbyNode, Reporter } from 'gatsby'; | ||
| import { GatsbyNode } from 'gatsby'; | ||
| import { examples, DEFAULT_EXAMPLE_LANGUAGES } from '../../src/data/examples/'; | ||
| import { Example } from '../../src/data/examples/types'; | ||
|
|
||
|
|
@@ -252,7 +252,9 @@ export const createPages: GatsbyNode['createPages'] = async ({ | |
| // with nginx redirects | ||
| writeRedirect(redirectFrom, pagePath); | ||
| } else { | ||
| reporter.info(`[REDIRECTS] Skipping hash fragment redirect: ${redirectFrom} (hash: ${redirectFromUrl.hash})`); | ||
| reporter.info( | ||
| `[REDIRECTS] Skipping hash fragment redirect: ${redirectFrom} (hash: ${redirectFromUrl.hash})`, | ||
| ); | ||
| } | ||
|
|
||
| createRedirect({ | ||
|
|
@@ -276,7 +278,7 @@ export const createPages: GatsbyNode['createPages'] = async ({ | |
| contentOrderedList, | ||
| contentMenu: contentMenuObject, | ||
| script, | ||
| layout: { leftSidebar: true, rightSidebar: true, searchBar: true, template: 'base' }, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| layout: { leftSidebar: true, rightSidebar: true, template: 'base' }, | ||
| }, | ||
| }); | ||
| return slug; | ||
|
|
@@ -331,7 +333,7 @@ export const createPages: GatsbyNode['createPages'] = async ({ | |
| component: examplesTemplate, | ||
| context: { | ||
| example, | ||
| layout: { sidebar: false, searchBar: false, template: 'examples' }, | ||
| layout: { sidebar: false, template: 'examples' }, | ||
| }, | ||
| }); | ||
| }; | ||
|
|
@@ -350,7 +352,9 @@ export const createPages: GatsbyNode['createPages'] = async ({ | |
| // with nginx redirects | ||
| writeRedirect(redirectFrom, toPath); | ||
| } else { | ||
| reporter.info(`[REDIRECTS] Skipping MDX hash fragment redirect: ${redirectFrom} (hash: ${redirectFromUrl.hash})`); | ||
| reporter.info( | ||
| `[REDIRECTS] Skipping MDX hash fragment redirect: ${redirectFrom} (hash: ${redirectFromUrl.hash})`, | ||
| ); | ||
| } | ||
|
|
||
| createRedirect({ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -214,28 +214,30 @@ function convertImagePathsToGitHub(content: string): string { | |
| const githubBaseUrl = 'https://raw.githubusercontent.com/ably/docs/main/src'; | ||
| const imageExtensions = '(?:png|jpg|jpeg|gif|svg|webp|bmp|ico)'; | ||
|
|
||
| return content | ||
| // Handle relative paths: ../../../images/...{ext} | ||
| .replace( | ||
| new RegExp(`!\\[([^\\]]*)\\]\\(((?:\\.\\.\\/)+)(images\\/[^)]+\\.${imageExtensions})\\)`, 'gi'), | ||
| (match, altText, relativePath, imagePath) => { | ||
| return ``; | ||
| } | ||
| ) | ||
| // Handle absolute paths: /images/...{ext} | ||
| .replace( | ||
| new RegExp(`!\\[([^\\]]*)\\]\\(\\/(images\\/[^)]+\\.${imageExtensions})\\)`, 'gi'), | ||
| (match, altText, imagePath) => { | ||
| return ``; | ||
| } | ||
| ) | ||
| // Handle direct paths: images/...{ext} (no prefix) | ||
| .replace( | ||
| new RegExp(`!\\[([^\\]]*)\\]\\((images\\/[^)]+\\.${imageExtensions})\\)`, 'gi'), | ||
| (match, altText, imagePath) => { | ||
| return ``; | ||
| } | ||
| ); | ||
| return ( | ||
| content | ||
| // Handle relative paths: ../../../images/...{ext} | ||
| .replace( | ||
| new RegExp(`!\\[([^\\]]*)\\]\\(((?:\\.\\.\\/)+)(images\\/[^)]+\\.${imageExtensions})\\)`, 'gi'), | ||
| (match, altText, relativePath, imagePath) => { | ||
| return ``; | ||
| }, | ||
| ) | ||
| // Handle absolute paths: /images/...{ext} | ||
| .replace( | ||
| new RegExp(`!\\[([^\\]]*)\\]\\(\\/(images\\/[^)]+\\.${imageExtensions})\\)`, 'gi'), | ||
| (match, altText, imagePath) => { | ||
| return ``; | ||
| }, | ||
| ) | ||
| // Handle direct paths: images/...{ext} (no prefix) | ||
| .replace( | ||
| new RegExp(`!\\[([^\\]]*)\\]\\((images\\/[^)]+\\.${imageExtensions})\\)`, 'gi'), | ||
| (match, altText, imagePath) => { | ||
| return ``; | ||
| }, | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -248,37 +250,32 @@ function convertRelativeUrls(content: string, siteUrl: string): string { | |
|
|
||
| // Match markdown links: [text](url) | ||
| // Only convert URLs that start with / (relative) and are not external URLs or hash-only | ||
| return content.replace( | ||
| /\[([^\]]+)\]\(([^)]+)\)/g, | ||
| (match, linkText, url) => { | ||
| // Don't convert external URLs | ||
| if (url.startsWith('http://') || url.startsWith('https://')) { | ||
| return match; | ||
| } | ||
|
|
||
| // Don't convert hash-only anchors | ||
| if (url.startsWith('#')) { | ||
| return match; | ||
| } | ||
|
|
||
| // Convert relative URLs (starting with /) | ||
| if (url.startsWith('/')) { | ||
| return `[${linkText}](${baseUrl}${url})`; | ||
| } | ||
| return content.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (match, linkText, url) => { | ||
| // Don't convert external URLs | ||
| if (url.startsWith('http://') || url.startsWith('https://')) { | ||
| return match; | ||
| } | ||
|
|
||
| // Keep other URLs as-is (relative paths without leading /) | ||
| // Don't convert hash-only anchors | ||
| if (url.startsWith('#')) { | ||
| return match; | ||
| } | ||
| ); | ||
|
|
||
| // Convert relative URLs (starting with /) | ||
| if (url.startsWith('/')) { | ||
| return `[${linkText}](${baseUrl}${url})`; | ||
| } | ||
|
|
||
| // Keep other URLs as-is (relative paths without leading /) | ||
| return match; | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Replace template variables with readable placeholders | ||
| */ | ||
| function replaceTemplateVariables(content: string): string { | ||
| return content | ||
| .replace(/{{API_KEY}}/g, 'your-api-key') | ||
| .replace(/{{RANDOM_CHANNEL_NAME}}/g, 'your-channel-name'); | ||
| return content.replace(/{{API_KEY}}/g, 'your-api-key').replace(/{{RANDOM_CHANNEL_NAME}}/g, 'your-channel-name'); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -309,7 +306,10 @@ function calculateOutputPath(relativeDirectory: string, fileName: string): strin | |
| /** | ||
| * Transform MDX content to clean Markdown | ||
| */ | ||
| function transformMdxToMarkdown(sourceContent: string, siteUrl: string): { content: string; title: string } { | ||
| function transformMdxToMarkdown( | ||
| sourceContent: string, | ||
| siteUrl: string, | ||
| ): { content: string; title: string; intro?: string } { | ||
| // Stage 1: Parse frontmatter | ||
| const parsed = frontMatter<FrontMatterAttributes>(sourceContent); | ||
|
|
||
|
|
@@ -318,6 +318,7 @@ function transformMdxToMarkdown(sourceContent: string, siteUrl: string): { conte | |
| } | ||
|
|
||
| const title = parsed.attributes.title; | ||
| const intro = parsed.attributes.intro; | ||
| let content = parsed.body; | ||
|
|
||
| // Stage 2: Remove import/export statements | ||
|
|
@@ -342,9 +343,9 @@ function transformMdxToMarkdown(sourceContent: string, siteUrl: string): { conte | |
| content = replaceTemplateVariables(content); | ||
|
|
||
| // Stage 9: Prepend title as markdown heading | ||
| const finalContent = `# ${title}\n\n${content}`; | ||
| const finalContent = `# ${title}\n\n${intro ? `${intro}\n\n` : ''}${content}`; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All other changes here are prettier - this is the key change. |
||
|
|
||
| return { content: finalContent, title }; | ||
| return { content: finalContent, title, intro }; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -404,9 +405,7 @@ export const onPostBuild: GatsbyNode['onPostBuild'] = async ({ graphql, reporter | |
| const { data, errors } = await graphql<MdxQueryResult>(query); | ||
|
|
||
| if (errors) { | ||
| reporter.panicOnBuild( | ||
| `${REPORTER_PREFIX} Error running GraphQL query: ${JSON.stringify(errors)}` | ||
| ); | ||
| reporter.panicOnBuild(`${REPORTER_PREFIX} Error running GraphQL query: ${JSON.stringify(errors)}`); | ||
| return; | ||
| } | ||
|
|
||
|
|
@@ -420,7 +419,7 @@ export const onPostBuild: GatsbyNode['onPostBuild'] = async ({ graphql, reporter | |
|
|
||
| if (!siteUrl) { | ||
| reporter.panicOnBuild( | ||
| `${REPORTER_PREFIX} siteUrl is not configured in siteMetadata. Please check gatsby-config.ts` | ||
| `${REPORTER_PREFIX} siteUrl is not configured in siteMetadata. Please check gatsby-config.ts`, | ||
| ); | ||
| return; | ||
| } | ||
|
|
@@ -442,22 +441,16 @@ export const onPostBuild: GatsbyNode['onPostBuild'] = async ({ graphql, reporter | |
| successCount++; | ||
| } catch (error) { | ||
| const errorMessage = error instanceof Error ? error.message : String(error); | ||
| reporter.warn( | ||
| `${REPORTER_PREFIX} Failed to transpile ${node.internal.contentFilePath}: ${errorMessage}` | ||
| ); | ||
| reporter.warn(`${REPORTER_PREFIX} Failed to transpile ${node.internal.contentFilePath}: ${errorMessage}`); | ||
| failureCount++; | ||
| } | ||
| } | ||
|
|
||
| // Report summary | ||
| if (failureCount > 0) { | ||
| reporter.warn( | ||
| `${REPORTER_PREFIX} Transpiled ${successCount} files, ${failureCount} failed` | ||
| ); | ||
| reporter.warn(`${REPORTER_PREFIX} Transpiled ${successCount} files, ${failureCount} failed`); | ||
| } else { | ||
| reporter.info( | ||
| `${REPORTER_PREFIX} Successfully transpiled ${successCount} MDX files to Markdown` | ||
| ); | ||
| reporter.info(`${REPORTER_PREFIX} Successfully transpiled ${successCount} MDX files to Markdown`); | ||
| } | ||
| }; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This wasn't used