Skip to content

Commit

Permalink
#25959 adding preview component
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelrojas committed Oct 17, 2023
1 parent 2f9a16c commit b376597
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 21 deletions.
Expand Up @@ -532,12 +532,9 @@ browse from the page internal links
this.isEditMode = true;
});
} else {
this.dotEditContentHtmlService.renderPage(pageState, this.iframe);
this.dotPageStateService.state$.subscribe(() => {
if (pageState.seoMedia) {
this.seoOGTags = this.dotEditContentHtmlService.getMetaTags();
this.seoOGTagsResults = this.dotEditContentHtmlService.getMetaTagsResults();
}
this.dotEditContentHtmlService.renderPage(pageState, this.iframe).then(() => {
this.seoOGTags = this.dotEditContentHtmlService.getMetaTags();
this.seoOGTagsResults = this.dotEditContentHtmlService.getMetaTagsResults();
});
this.isEditMode = false;
}
Expand Down
Expand Up @@ -27,6 +27,7 @@ import {
@Injectable()
export class DotSeoMetaTagsService {
readMoreValues: Record<SEO_MEDIA_TYPES, string[]>;
seoMedia: string;

constructor(
private dotMessageService: DotMessageService,
Expand Down Expand Up @@ -760,11 +761,19 @@ export class DotSeoMetaTagsService {
}

/**
* This uploads the image temporaly to get the file size, only if it is external
* This uploads the image temporaly to get the file size, only if it is external.
* Checks if the imageUrl has been sent or seoMedia is not null.
* @param imageUrl string
* @returns
*/
getImageFileSize(imageUrl: string): Observable<DotCMSTempFile | ImageMetaData> {
if (!imageUrl) {
return of({
length: 0,
url: IMG_NOT_FOUND_KEY
});
}

return from(fetch(imageUrl)).pipe(
mergeMap((response) => {
if (response.status === 404) {
Expand Down
Expand Up @@ -13,10 +13,18 @@
[class.results-seo-tool__version--small]="preview.isMobile"
data-testId="seo-preview-mobile">
<div class="results-seo-tool__card-title">
<img
<div
class="results-seo-tool__card-favicon"
[src]="seoOGTags.favicon"
alt="favicon" />
*ngIf="noFavicon; else favicon">
<i class="pi pi-globe"></i>
</div>
<ng-template #favicon>
<img
class="results-seo-tool__card-favicon"
[src]="seoOGTags.favicon"
(error)="onFaviconError()"
alt="favicon" />
</ng-template>
<span data-testId="page-hostName">{{ preview.hostName }}</span>
</div>
<a
Expand All @@ -33,15 +41,15 @@
</div>
</div>
<div *ngSwitchCase="seoMediaTypes.TWITTER">
<dot-seo-image-preview image="mainPreview.image"></dot-seo-image-preview>
<dot-seo-image-preview [image]="mainPreview.image"></dot-seo-image-preview>
<div class="results-seo-tool__preview">
<span data-testId="page-hostName">{{ mainPreview.hostName }}</span>
<h5>{{ mainPreview.twitterTitle }}</h5>
<p>{{ mainPreview.twitterDescription }}</p>
</div>
</div>
<div *ngSwitchDefault>
<dot-seo-image-preview image="mainPreview.image"></dot-seo-image-preview>
<dot-seo-image-preview [image]="mainPreview.image"></dot-seo-image-preview>
<div class="results-seo-tool__preview">
<span data-testId="page-hostName">{{ mainPreview.hostName }}</span>
<h5>{{ mainPreview.title }}</h5>
Expand Down
Expand Up @@ -48,6 +48,7 @@
border-radius: 6.25rem;
background: $color-palette-gray-200;
padding: $spacing-1;
color: $color-palette-gray-800;
}

.results-seo-tool__search-title {
Expand Down
Expand Up @@ -67,7 +67,7 @@ export class DotResultsSeoToolComponent implements OnInit, OnChanges {
allPreview: MetaTagsPreview[];
mainPreview: MetaTagsPreview;
seoMediaTypes = SEO_MEDIA_TYPES;
defaultPreview = false;
noFavicon = false;

ngOnInit() {
const title =
Expand Down Expand Up @@ -120,4 +120,8 @@ export class DotResultsSeoToolComponent implements OnInit, OnChanges {
})
);
}

onFaviconError(): void {
this.noFavicon = true;
}
}
Expand Up @@ -4,8 +4,8 @@ <h5>{{ 'seo.rules.media.preview.not.defined' | dm }}</h5>
</div>
<ng-template #imagePreview>
<img
class="results-seo-tool__preview-image"
class="dot-seo-image-preview__image"
[src]="image"
(error)="onImageError($event)"
(error)="onImageError()"
alt="preview image" />
</ng-template>
Expand Up @@ -18,17 +18,12 @@ $image-height: 23.875rem;
flex-direction: column;
color: $black;
background-color: $color-palette-gray-100;

.pi {
font-size: $font-size-xxl;
color: $color-alert-red;
}
}

:host ::ng-deep {
.dot-seo-image-preview__default {
.pi {
font-size: 2.5rem;
font-size: $font-size-xxxl;
color: $color-alert-red;
}
}
Expand Down

0 comments on commit b376597

Please sign in to comment.