Skip to content

Allow submodule version aliases for import paths #202

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 2 commits into from
May 9, 2025

Conversation

ptgott
Copy link
Contributor

@ptgott ptgott commented Apr 30, 2025

Closes #195

Add a remark plugin that lets a docs author include an import statement that points to a directory in the current version submodule of the docs site. This makes it possible to import the path of a static asset or, with the !!raw-loader! directive, the full content, using an import statement, without having to know which versioned submodule an asset is in at a given time.

To use this, add the string @version to the start of an import path, e.g.,:

import PNGPath from '@version/docs/img/myimg.png'

In a gravitational/teleport clone at the current default version of the docs site, the new plugin would add the following:

import PNGPath from '@site/content/17.x/docs/img/myimg.png'

Note that we currently use a workaround in which we place some static assets in the /static directory, which exists outside the submodule directory tree. This is approach is cumbersome since it requires a change to docs-website for every asset we want to include using an import statement.

The @site alias is a Docusaurus feature that the docs engine replaces with the root path of the Docusaurus project. The plugin fills in the path of the current gravitational/teleport submodule.

To import the content of a text asset, rather than the file path, you would use the !!raw-loader syntax as you would for any Docusaurus asset:

import PNGPath from '!!raw-loader!@version/docs/img/myimg.png'

Copy link

github-actions bot commented Apr 30, 2025

Amplify deployment status

Branch Commit Job ID Status Preview Updated (UTC)
paul.gottschling/2025-04-30-version-alias 5877372 12 ✅SUCCEED paul-gottschling-2025-04-30-version-alias 2025-05-09 13:09:41

@ptgott ptgott marked this pull request as ready for review April 30, 2025 19:37
@ptgott ptgott temporarily deployed to docs-amplify May 1, 2025 09:58 — with GitHub Actions Inactive
@ptgott ptgott force-pushed the paul.gottschling/2025-04-30-version-alias branch from 2ec7e17 to 4c62c93 Compare May 5, 2025 15:17
@ptgott ptgott temporarily deployed to docs-amplify May 5, 2025 15:17 — with GitHub Actions Inactive
@ptgott ptgott requested review from taraspos and avatus and removed request for taraspos May 5, 2025 15:18
Closes #195

Add a `remark` plugin that lets a docs author include an `import`
statement that points to a directory in the current version submodule of
the docs site. This makes it possible to import the path of a static
asset or, with the `!!raw-loader!` directive, the full content, using an
`import` statement, without having to know which versioned submodule an
asset is in at a given time.

To use this, add the string `@version` to the start of an import path,
e.g.,:

```jsx
import PNGPath from '@version/docs/img/myimg.png'
```

In a `gravitational/teleport` clone at the current default version of
the docs site, the new plugin would add the following:

```jsx
import PNGPath from '@site/content/17.x/docs/img/myimg.png'
```

Note that we currently use a workaround in which we place some static
assets in the `/static` directory, which exists outside the submodule
directory tree. This is approach is cumbersome since it requires a
change to `docs-website` for every asset we want to include using an
`import` statement.

The `@site` alias is a Docusaurus feature that the docs engine replaces
with the root path of the Docusaurus project. The plugin fills in the
path of the current `gravitational/teleport` submodule.

To import the content of a text asset, rather than the file path, you
would use the `!!raw-loader` syntax as you would for any Docusaurus
asset:

```jsx
import PNGPath from '!!raw-loader!@version/docs/img/myimg.png'
```
@ptgott ptgott force-pushed the paul.gottschling/2025-04-30-version-alias branch from 4c62c93 to d6e33f5 Compare May 6, 2025 18:46
@ptgott ptgott temporarily deployed to docs-amplify May 6, 2025 18:46 — with GitHub Actions Inactive
@avatus
Copy link

avatus commented May 6, 2025

for the dep review, you may need to add the variant that is failing there like this

but also, check and see if the dependency can maybe be updated or changed to a version that we might support (assuming the license changes). i know its a peer dep, so maybe not

@ptgott ptgott temporarily deployed to docs-amplify May 8, 2025 18:09 — with GitHub Actions Inactive
@ptgott
Copy link
Contributor Author

ptgott commented May 8, 2025

@avatus Thanks for taking a look! I'm a little leery of adding an allowed license variant since the variant is LicenseRef-scancode-unknown-license-reference, i.e., no clear license. What's also weird is that the only change to the license before the 1.11.11 release was a clarification of the copyright owners. Maybe the dot in the copyright statement is throwing off the dependency review pattern matcher?

@avatus
Copy link

avatus commented May 8, 2025

i think without making the license change, the only other options we have is somehow get them to change their license (we have fixed licenses before with PRs to other deps), or find another package that does something similar

Revert unnecessary dependency changes. Remove @types/estree. Also remove
an extraneous `mdast-util-mdxjs-esm` mention in `package.json`.

Add swc/core to the list of dependencies with allowed licenses for the
dependency review workflow. While the package uses the Apache 2.0
license, which is already configured as allowed in the workflow, the
workflow also detects an unknown license that does not appear to be
present in the package's code repository.
@ptgott ptgott force-pushed the paul.gottschling/2025-04-30-version-alias branch from 4a45319 to 5877372 Compare May 9, 2025 12:57
@ptgott ptgott temporarily deployed to docs-amplify May 9, 2025 12:57 — with GitHub Actions Inactive
@avatus
Copy link

avatus commented May 9, 2025

You rock!!

@ptgott ptgott added this pull request to the merge queue May 9, 2025
Merged via the queue into main with commit 650a7ed May 9, 2025
6 checks passed
@ptgott ptgott deleted the paul.gottschling/2025-04-30-version-alias branch May 9, 2025 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a remark plugin to replace a @version path segment alias
2 participants