Skip to content
Snippets Groups Projects
Verified Commit 262ab003 authored by Jonas Leder's avatar Jonas Leder
Browse files

use s3img for internal images

parent 741be555
Branches
No related tags found
No related merge requests found
......@@ -4,13 +4,14 @@ import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component';
import {HttpClientModule} from "@angular/common/http";
import { HttpClient, HttpClientModule } from "@angular/common/http";
import { ContentComponent } from './content/content.component';
import {MarkdownModule} from "ngx-markdown";
import { MarkdownModule, MarkedOptions } from "ngx-markdown";
import { S3imgComponent } from './s3img/s3img.component';
import { DynamicHooksModule, HookParserEntry } from 'ngx-dynamic-hooks';
import { SkillsComponent } from './skills/skills.component';
import { BlogComponent } from './blog/blog.component';
import { markedOptionsFactory } from './markdownOptions';
const componentParsers: Array<HookParserEntry> = [
{ component: S3imgComponent },
......@@ -31,7 +32,13 @@ const componentParsers: Array<HookParserEntry> = [
AppRoutingModule,
HttpClientModule,
MarkdownModule,
MarkdownModule.forRoot(),
MarkdownModule.forRoot({
loader: HttpClient,
markedOptions: {
provide: MarkedOptions,
useFactory: markedOptionsFactory,
}
}),
DynamicHooksModule.forRoot({
globalParsers: componentParsers
})
......
import { MarkedOptions, MarkedRenderer } from 'ngx-markdown';
export function markedOptionsFactory(): MarkedOptions {
const renderer = new MarkedRenderer();
renderer.image = (href: string, title: string, text: string) => {
if(RegExp('^https?:\/\/|\/\/').test(href)) {
return `<img src="${href}" alt="${text}">`;
} else {
return `<s3img src="${href}"></s3img>`;
}
};
return {
renderer: renderer,
gfm: true,
breaks: false,
pedantic: false,
smartLists: true,
smartypants: false,
};
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment