Skip to content

Commit

Permalink
chore: enable images in md files
Browse files Browse the repository at this point in the history
  • Loading branch information
okadurin committed Nov 7, 2023
1 parent 0339ef4 commit d743778
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,6 @@ They provide an unopinionated, white-label layer that can be extended to your ow
IconManager.js?v=8cca74f1:22 Uncaught Error: An icon resolver has already been registered for namespace: lion
```

- Fix import loding from inside md files. Navigate to [ing-open-sources-lion](http://localhost:4322/blog/ing-open-sources-lion), [formatting-and-parsing](http://localhost:4322/fundamentals/systems/form/formatting-and-parsing) The build error appears:

```
4:43:56 PM [vite] Error when evaluating SSR module /Users/ai09al/ing/lion/src/content/docs/blog/ing-open-sources-lion.md: failed to import "./images/ing-open-sources-lion-side-by-side.png"
|- ImageNotFound: Could not find requested image `./images/ing-open-sources-lion-side-by-side.png`. Does it exist?
```

It seems `vite` tries to resolve the paths in `md`s instead of letting them as they are.

- Navigate to [providence-analytics/overview](http://localhost:4322/fundamentals/node-tools/providence-analytics/overview). The corresponding md file could be found by docs/fundamentals/node-tools/providence-analytics/overview.md. It contains notation like this: `![CLI](./assets/provicli.gif 'CLI')`. Which throws an error:

```
Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"astro-seo": "^0.8.0",
"changeset": "^0.2.6",
"find-node-modules": "^2.1.3",
"image-extensions": "^1.1.0",
"npm-watch": "^0.11.0"
},
"devDependencies": {
Expand Down
7 changes: 6 additions & 1 deletion src/utils/copy-docs/copy-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const path = require('path');
const fs = require('fs/promises');
const process = require('process');
// eslint-disable-next-line import/no-extraneous-dependencies
const imageExtensions = require('image-extensions');
// eslint-disable-next-line import/no-extraneous-dependencies
const findNodeModules = require('find-node-modules');
// eslint-disable-next-line import/no-extraneous-dependencies
const { init, parse } = require('es-module-lexer');
Expand Down Expand Up @@ -93,7 +95,10 @@ async function copyDocs(currentPath = '') {
}
await copyDocs(path.join(currentPath, file));
} else {
if (path.extname(file) === '.md' && file !== 'index.md') {
if (
(path.extname(file) === '.md' && file !== 'index.md') ||
imageExtensions.includes(path.extname(file).split('.')[1])
) {
await fs.mkdir(path.join(contentDocsPath, currentPath), { recursive: true });
await fs.copyFile(sourceDocsFilePath, contentDocsFilePath);

Expand Down

0 comments on commit d743778

Please sign in to comment.