-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3057a8
commit 92babfe
Showing
17 changed files
with
210 additions
and
67 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
flex-direction: column; | ||
gap: 24px; | ||
overflow: hidden; | ||
margin-bottom: 50px; | ||
} | ||
|
||
.toc { | ||
|
This file contains 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 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 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
3 changes: 3 additions & 0 deletions
3
src/theme/BlogPostItem/Header/TitleWithHighlights/index.module.scss
This file contains 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.highlight { | ||
color: var(--logto-link-color); | ||
} |
44 changes: 44 additions & 0 deletions
44
src/theme/BlogPostItem/Header/TitleWithHighlights/index.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { type PropBlogPostMetadata } from '@docusaurus/plugin-content-blog'; | ||
import { condString } from '@silverhand/essentials'; | ||
|
||
import styles from './index.module.scss'; | ||
|
||
type Props = { | ||
readonly metadata: PropBlogPostMetadata; | ||
}; | ||
|
||
/** | ||
* Escape potential parentheses in the SDK / connector name. | ||
* The result will be used for the regex that splits the title into parts. | ||
*/ | ||
const normalizeName = (name: string) => name.replaceAll('(', '\\(').replaceAll(')', '\\)'); | ||
|
||
const TitleWithHighlights = ({ metadata }: Props) => { | ||
const { frontMatter, title } = metadata; | ||
const sdkName = condString('sdk' in frontMatter && frontMatter.sdk); | ||
const connectorName = condString('connector' in frontMatter && frontMatter.connector); | ||
|
||
const titleParts = title | ||
.split(new RegExp(`(${normalizeName(connectorName)}|${normalizeName(sdkName)})`, 'g')) | ||
.filter(Boolean); | ||
|
||
return titleParts.map((part) => { | ||
if (part === sdkName) { | ||
return ( | ||
<span key={`${frontMatter.slug}-${sdkName}`} className={styles.highlight}> | ||
{part} | ||
</span> | ||
); | ||
} | ||
if (part === connectorName) { | ||
return ( | ||
<span key={`${frontMatter.slug}-${connectorName}`} className={styles.highlight}> | ||
{part} | ||
</span> | ||
); | ||
} | ||
return part; | ||
}); | ||
}; | ||
|
||
export default TitleWithHighlights; |
This file contains 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 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 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.