Skip to content

Commit

Permalink
Fix images
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlarkworthy committed Jun 13, 2020
1 parent 13b73d3 commit f69376b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Hero](/hero.png)
![Hero](_header_/hero.png)

# Repository containing various Terraform code

Expand Down Expand Up @@ -1239,7 +1239,7 @@ Hosting static website using S3 is a very cost effective approach. Since, S3 web

## Architecture

![Architecture](images/s3-static-website.png)
![Architecture](aws/static_website_ssl_cloudfront_private_s3/images/s3-static-website.png)



Expand Down
15 changes: 8 additions & 7 deletions repotools/generate_readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,21 @@ class AddSection extends Transform {
}
}

// BUGGY
// Convert
// ![test1](./myImage1.png)
// ![test1](<path>/<filename>.png) in <dir>
// to
// ![image](/download/attachments/37064693/myImage1.png)
// ![image](<dir>/<path>/<filename>.png)
class RebaseImages extends Transform {
constructor(options) {
super(options);
this.directory = options.directory;
}
_transform(data, encoding, callback) {
const pattern = /!\[.+\]\(\.(\/.+\.png)\)/g;
const replace = "![image](/download/attachments/37064693$1)";
const pattern = /!\[(?<label>[^\]]*)\]\((?<filepath>[^)]*)\)/g;
const replace = `![$1](${this.directory}/$2)`;

const newData = data.toString()
.replace(pattern, replace);

this.push(newData);

callback();
Expand Down Expand Up @@ -130,7 +129,9 @@ glob('*/**/*.md', (err, files) => {
source: file,
files: files
}))
.pipe(new RebaseImages())
.pipe(new RebaseImages({
directory: directory(file)
}))
.pipe(new ConvertLinksToAnchors())
.on("finish", (err) => resolve())
.pipe(output, {end: false})
Expand Down

0 comments on commit f69376b

Please sign in to comment.