Skip to content

Commit

Permalink
feat(docs): Add dynamic meta tags for connector documentation (#48458)
Browse files Browse the repository at this point in the history
  • Loading branch information
letiescanciano authored Nov 19, 2024
1 parent c6d49bd commit 8b9a801
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/using-airbyte/getting-started/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ looking to scale efficiently. For more details, talk to our Sales team. " ctaTex

<Grid columns="1">

<CardWithIcon title="pyAirbyte" description="Quickly sync data using Python in your local notebook." ctaText="OSS Quickstart" ctaLink="pyairbyte/getting-started" icon="fa-download" />
<CardWithIcon title="pyAirbyte" description="Quickly sync data using Python in your local notebook." ctaText="OSS Quickstart" ctaLink="../pyairbyte/getting-started" icon="fa-download" />


</Grid>
Expand Down
2 changes: 2 additions & 0 deletions docusaurus/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const enterpriseDocsHeaderInformation = require("./src/remark/enterpriseDocsHead
const productInformation = require("./src/remark/productInformation");
const connectorList = require("./src/remark/connectorList");
const specDecoration = require("./src/remark/specDecoration");
const docMetaTags = require("./src/remark/docMetaTags");

const redirects = yaml.load(
fs.readFileSync(path.join(__dirname, "redirects.yml"), "utf-8")
Expand Down Expand Up @@ -113,6 +114,7 @@ const config = {
docsHeaderDecoration,
enterpriseDocsHeaderInformation,
productInformation,
docMetaTags,
],
},
blog: false,
Expand Down
11 changes: 11 additions & 0 deletions docusaurus/src/components/DocMetaTags.jsx
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>
);
};
40 changes: 40 additions & 0 deletions docusaurus/src/remark/docMetaTags.js
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;
2 changes: 2 additions & 0 deletions docusaurus/src/theme/MDXComponents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { SpecSchema } from "@site/src/components/SpecSchema";
import MDXComponents from "@theme-original/MDXComponents";
import { CardWithIcon } from "../../components/Card/Card";
import { Details } from "../../components/Details";
import { DocMetaTags } from "../../components/DocMetaTags";
import { EntityRelationshipDiagram } from "../../components/EntityRelationshipDiagram";
import { Grid } from "../../components/Grid/Grid";
import { YoutubeEmbed } from "../../components/YoutubeEmbed";
Expand All @@ -30,4 +31,5 @@ export default {
CardWithIcon,
Grid,
YoutubeEmbed,
DocMetaTags,
};

0 comments on commit 8b9a801

Please sign in to comment.