This commit is contained in:
Rachael Sewell 2022-07-11 14:06:53 -07:00 коммит произвёл GitHub
Родитель e5f8d1c78a
Коммит efaf5f825d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 1 добавлений и 51 удалений

Просмотреть файл

@ -334,7 +334,7 @@ Just add a hyphen on either the left, right, or both sides to indicate that ther
{%- ifversion fpt %}
```
## Links and image paths
## Links
Links to docs in the `docs-internal` repository must start with a product ID (like `/actions` or `/admin`) and contain the entire filepath, but not the file extension. For example, `/actions/creating-actions/about-custom-actions`.
@ -356,8 +356,6 @@ and when viewed on GitHub Enterprise Server docs, the version is included as wel
/en/enterprise-server@2.20/github/writing-on-github/creating-a-saved-reply
```
There are transformations for image paths in GitHub Enterprise Server (versions 2.20-3.0) only. Once those versions are deprecation, there will no longer be any transformations for image paths. For more information, see [/assets/images/enterprise/legacy-format/README.md](/assets/images/enterprise/legacy-format/README.md).
### Preventing transformations
Sometimes you want to link to a Dotcom-only article in Enterprise content and you don't want the link to be Enterprise-ified. To prevent the transformation, include the preferred version in the path.

Просмотреть файл

@ -20,7 +20,6 @@ import codeHeader from './plugins/code-header.js'
import rewriteLocalLinks from './plugins/rewrite-local-links.js'
import rewriteImgSources from './plugins/rewrite-asset-urls.js'
import useEnglishHeadings from './plugins/use-english-headings.js'
import rewriteLegacyAssetPaths from './plugins/rewrite-legacy-asset-paths.js'
import wrapInElement from './plugins/wrap-in-element.js'
import doctocatLinkIcon from './doctocat-link-icon.js'
const graphql = HighlightjsGraphql.definer
@ -52,7 +51,6 @@ export default function createProcessor(context) {
subset: false,
})
.use(raw)
.use(rewriteLegacyAssetPaths, context)
.use(wrapInElement, { selector: 'ol > li img', wrapper: 'span.procedural-image-wrapper' })
.use(DISABLE_REWRITE_ASSET_URLS ? null : rewriteImgSources)
.use(rewriteLocalLinks, {

Просмотреть файл

@ -1,46 +0,0 @@
import { visit } from 'unist-util-visit'
import fs from 'fs'
import { legacyAssetVersions } from '../../enterprise-server-releases.js'
import { allVersions } from '../../all-versions.js'
const matcher = (node) =>
node.type === 'element' &&
node.tagName === 'img' &&
node.properties.src &&
node.properties.src.startsWith('/assets/images')
// This module rewrites asset paths for specific Enterprise versions that
// were migrated from AWS S3 image storage. Only images that were unique
// were stored in a new /assets/enterprise path. Once these versions are
// deprecated, we will have one source of truth for image assets and we
// can remove this module.
// Source example: /assets/images/foo.png
// Rewritten: /assets/enterprise/2.20/assets/images/foo.png
export default function checkForLegacyAssetPaths({ currentVersion, relativePath }) {
// Bail if we don't have a relativePath in this context
if (!relativePath) return
// skip if this is the homepage
if (relativePath === 'index.md') return
// skip for any versions that aren't enterprise-server
if (!allVersions[currentVersion].plan === 'enterprise-server') return
const enterpriseRelease = allVersions[currentVersion].currentRelease
if (!legacyAssetVersions.includes(enterpriseRelease)) return
return async (tree) => {
const promises = []
visit(tree, matcher, visitor)
await Promise.all(promises)
function visitor(node) {
const legacyAssetPath = `/assets/images/enterprise/legacy-format/${enterpriseRelease}${node.properties.src}`
const p = fs.promises
.access(`${process.cwd()}${legacyAssetPath}`, fs.constants.F_OK)
// rewrite the nodes src
.then(() => {
node.properties.src = `${legacyAssetPath}`
})
.catch(() => node)
promises.push(p)
}
}
}