-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs): Add dynamic meta tags for connector documentation (#48458)
- Loading branch information
1 parent
c6d49bd
commit 8b9a801
Showing
5 changed files
with
56 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Head from "@docusaurus/Head"; | ||
|
||
export const DocMetaTags = (props) => { | ||
const { title, description } = props; | ||
return ( | ||
<Head> | ||
<title>{title}</title> | ||
<meta name="description" content={description} /> | ||
</Head> | ||
); | ||
}; |
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,40 @@ | ||
const { default: React } = require("react"); | ||
const { getFromPaths, toAttributes } = require("../helpers/objects"); | ||
const { isDocsPage, getRegistryEntry } = require("./utils"); | ||
const visit = require("unist-util-visit").visit; | ||
|
||
const generateMetaTags = (connectorName) => { | ||
return { | ||
title: `${connectorName} Connector | Airbyte Documentation`, | ||
description: `Connect ${connectorName} to our ETL/ELT platform for streamlined data integration, automated syncing, and powerful data insights.`, | ||
}; | ||
}; | ||
const plugin = () => { | ||
const transformer = async (ast, vfile) => { | ||
const docsPageInfo = isDocsPage(vfile); | ||
if (!docsPageInfo.isDocsPage) return; | ||
|
||
const registryEntry = await getRegistryEntry(vfile); | ||
|
||
if (!registryEntry) return; | ||
|
||
visit(ast, "heading", (node) => { | ||
const name = getFromPaths(registryEntry, "name_[oss|cloud]"); | ||
console.log("name", name); | ||
const { title, description } = generateMetaTags(name); | ||
|
||
const attributes = toAttributes({ | ||
title, | ||
description, | ||
}); | ||
|
||
node.children = []; | ||
node.type = "mdxJsxFlowElement"; | ||
node.name = "DocMetaTags"; | ||
node.attributes = attributes; | ||
}); | ||
}; | ||
return transformer; | ||
}; | ||
|
||
module.exports = plugin; |
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