website: fix edit links for remote plugins (#10884)

* website: fix issue with edits links, use branch name, not version

* website: patch layout shift issue related to global style

* website: update plugin config docs with sourceBranch

* website: tweak spacing above plugin tier label

* website: add note on default value for sourceBranch
pull/10894/head
Zachary Shilton 5 years ago committed by GitHub
parent cf94fd1778
commit ab0d1ee363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -29,12 +29,6 @@ to match Terraform Registry tier labels.
}
}
/* add margin-top to separate from the adjacent
search bar present on docs pages */
:global(.g-search) + .root {
margin-top: 40px;
}
.text {
/* composes */
composes: g-type-body-small-strong from global;

@ -54,7 +54,7 @@ async function generateStaticProps({
// (current options are "Official" or "Community")
function mdxContentHook(mdxContent) {
if (pluginTier) {
const tierMdx = `<PluginTierLabel tier="${pluginTier}" />\n\n`
const tierMdx = `<br/><PluginTierLabel tier="${pluginTier}" />\n\n`
mdxContent = tierMdx + mdxContent
}
return mdxContent

@ -132,7 +132,13 @@ async function mergeRemotePlugins(remotePluginsFile, navData, currentPath) {
// which contains { filePath, fileString } data for the remote
// plugin doc .mdx file
async function resolvePluginEntryDocs(pluginConfigEntry, currentPath) {
const { title, path: slug, repo, version } = pluginConfigEntry
const {
title,
path: slug,
repo,
version,
sourceBranch = 'main',
} = pluginConfigEntry
const docsMdxFiles = await fetchPluginDocs({ repo, tag: version })
// We construct a special kind of "NavLeaf" node, with a remoteFile property,
// consisting of a { filePath, fileString, sourceUrl }, where:
@ -155,7 +161,7 @@ async function resolvePluginEntryDocs(pluginConfigEntry, currentPath) {
const { nav_title, sidebar_title } = frontmatter
const title = nav_title || sidebar_title || basename
// construct sourceUrl (used for "Edit this page" link)
const sourceUrl = `https://github.com/${repo}/blob/${version}/${filePath}`
const sourceUrl = `https://github.com/${repo}/blob/${sourceBranch}/${filePath}`
// determine pluginTier
const pluginOwner = repo.split('/')[0]
const pluginTier = pluginOwner === 'hashicorp' ? 'official' : 'community'

@ -247,21 +247,6 @@ To include plugin docs on Packer.io a global pre-hook has been added to the main
The `docs.zip` file will contain all of the `.mdx` files under the plugins root `docs/` directory that can be consumed remotely by Packer.io.
Once the first `docs.zip` file has been included into a release you will need to open a one time pull-request against [hashicorp/packer](https://github.com/hashicorp/packer) to register the plugin docs.
This is done by adding the block below for the respective plugin to the file [website/data/docs-remote-navigation.js](https://github.com/hashicorp/packer/blob/master/website/data/docs-remote-plugins.json).
```json
{
"title": "Scaffolding",
"path": "scaffolding",
"repo": "hashicorp/packer-plugin-scaffolding",
"version": "latest"
}
```
If a plugin maintainer wishes to only include a specific version of released docs then the `"version"` key in the above configuration should be set to a released version of the plugin. Otherwise it should be set to "latest".
</Tab>
<Tab heading="Manually generating docs.zip">
@ -272,23 +257,26 @@ The documentation structure needed for Packer.io can be generated manually, by c
[[ -d docs/ ]] && zip -r docs.zip docs/
```
</Tab>
</Tabs>
Once the first `docs.zip` file has been included into a release you will need to open a one time pull-request against [hashicorp/packer](https://github.com/hashicorp/packer) to register the plugin docs.
This is done by adding the block below for the respective plugin to the file [website/data/docs-remote-navigation.js](https://github.com/hashicorp/packer/blob/master/website/data/docs-remote-plugins.json).
This is done by adding the block below for the respective plugin to the file [website/data/docs-remote-plugins.json](https://github.com/hashicorp/packer/blob/master/website/data/docs-remote-plugins.json).
```json
{
"title": "Scaffolding",
"path": "scaffolding",
"repo": "hashicorp/packer-plugin-scaffolding",
"version": "latest"
}
"title": "Scaffolding",
"path": "scaffolding",
"repo": "hashicorp/packer-plugin-scaffolding",
"version": "latest",
"sourceBranch": "main"
}
```
If a plugin maintainer wishes to only include a specific version of released docs then the `"version"` key in the above configuration should be set to a released version of the plugin. Otherwise it should be set to "latest".
If a plugin maintainer wishes to only include a specific version of released docs, then the `"version"` key in the above configuration should be set to a released version of the plugin. Otherwise it should be set to `"latest"`.
</Tab>
</Tabs>
The `"sourceBranch"` key in the above configuration ensures potential contributors can link back to source files in the plugin repository from the Packer docs site. If a `"sourceBranch"` value is not present, it will default to `"main"`.
### Plugin Development Tips and FAQs

Loading…
Cancel
Save