@studyportals/fawkes 8.1.3-1 → 8.1.3-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/structured-data/ScholarshipStructuredDataFactory.d.ts +1 -2
- package/dist/src/structured-data/ScholarshipStructuredDataFactory.js +2 -8
- package/dist/src/structured-data/SearchStructuredDataFactory.d.ts +2 -10
- package/dist/src/structured-data/SearchStructuredDataFactory.js +4 -13
- package/package.json +2 -2
|
@@ -5,10 +5,9 @@ import { IScholarshipCard } from "@studyportals/domain-client";
|
|
|
5
5
|
import { EntityDTO, OfferDTO, PaywallDTO } from "./dto";
|
|
6
6
|
export declare class ScholarshipStructuredDataFactory extends SearchStructuredDataFactory<IScholarshipCard> {
|
|
7
7
|
private currencyConversionService;
|
|
8
|
-
private cardIndex;
|
|
9
8
|
constructor(currencyConversionService: StructuredDataCurrencyConversionService);
|
|
10
9
|
protected buildStructuredDataForCard(entity: EntityDTO<IScholarshipCard>): Promise<MonetaryGrant | undefined>;
|
|
11
10
|
protected getOfferData(card: IScholarshipCard): Promise<OfferDTO | undefined>;
|
|
12
|
-
protected getPaywallData(
|
|
11
|
+
protected getPaywallData(): PaywallDTO | undefined;
|
|
13
12
|
private buildAmount;
|
|
14
13
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SearchStructuredDataFactory } from "./SearchStructuredDataFactory";
|
|
2
2
|
export class ScholarshipStructuredDataFactory extends SearchStructuredDataFactory {
|
|
3
3
|
currencyConversionService;
|
|
4
|
-
cardIndex = 0;
|
|
5
4
|
constructor(currencyConversionService) {
|
|
6
5
|
super();
|
|
7
6
|
this.currencyConversionService = currencyConversionService;
|
|
@@ -32,15 +31,10 @@ export class ScholarshipStructuredDataFactory extends SearchStructuredDataFactor
|
|
|
32
31
|
validFrom: undefined
|
|
33
32
|
};
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
getPaywallData(card) {
|
|
37
|
-
const currentIndex = this.cardIndex++;
|
|
38
|
-
if (currentIndex < 2) {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
34
|
+
getPaywallData() {
|
|
41
35
|
return {
|
|
42
36
|
isAccessibleForFree: false,
|
|
43
|
-
cssSelector: '.
|
|
37
|
+
cssSelector: '.Paywalled',
|
|
44
38
|
accessMode: 'registration'
|
|
45
39
|
};
|
|
46
40
|
}
|
|
@@ -6,7 +6,7 @@ import { FAQItemDto } from './dto/FAQItemDto';
|
|
|
6
6
|
import { BreadcrumbDTO } from './dto/BreadcrumbDTO';
|
|
7
7
|
import { PaywallDTO } from './dto/PaywallDTO';
|
|
8
8
|
export declare abstract class SearchStructuredDataFactory<TCard> {
|
|
9
|
-
buildStructuredData(title: string, description: string, cards: TCard[], faqItems?: FAQItemDto[], breadcrumbs?: BreadcrumbDTO[]
|
|
9
|
+
buildStructuredData(title: string, description: string, cards: TCard[], faqItems?: FAQItemDto[], breadcrumbs?: BreadcrumbDTO[]): Promise<WithContext<SearchResultsPage>>;
|
|
10
10
|
protected abstract buildStructuredDataForCard(entity: EntityDTO<TCard>): Promise<Thing | undefined> | Thing | undefined;
|
|
11
11
|
/**
|
|
12
12
|
* Get the rating for a card.
|
|
@@ -26,15 +26,7 @@ export declare abstract class SearchStructuredDataFactory<TCard> {
|
|
|
26
26
|
* @protected
|
|
27
27
|
*/
|
|
28
28
|
protected getOfferData(card: TCard): Promise<OfferDTO | undefined>;
|
|
29
|
-
|
|
30
|
-
* Get the paywall data for a card.
|
|
31
|
-
* This method should be overridden by subclasses to provide the specific paywall logic.
|
|
32
|
-
* If no paywall data is available, return undefined and no paywall information will be added to the card.
|
|
33
|
-
*
|
|
34
|
-
* @param card
|
|
35
|
-
* @protected
|
|
36
|
-
*/
|
|
37
|
-
protected getPaywallData(card: TCard): PaywallDTO | undefined;
|
|
29
|
+
protected getPaywallData(): PaywallDTO | undefined;
|
|
38
30
|
private constructOptionalPageOffers;
|
|
39
31
|
protected constructOptionalFaqPage(faqItems: FAQItemDto[]): FAQPage | undefined;
|
|
40
32
|
private constructOptionalPageParts;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
export class SearchStructuredDataFactory {
|
|
2
|
-
async buildStructuredData(title, description, cards, faqItems = [], breadcrumbs = []
|
|
2
|
+
async buildStructuredData(title, description, cards, faqItems = [], breadcrumbs = []) {
|
|
3
3
|
const entities = [];
|
|
4
4
|
const ratings = [];
|
|
5
5
|
const offersData = [];
|
|
6
6
|
for (const card of cards) {
|
|
7
7
|
const reviewRating = this.getRating(card);
|
|
8
8
|
const offer = await this.getOfferData(card);
|
|
9
|
-
const paywall = this.getPaywallData(card);
|
|
10
9
|
if (reviewRating)
|
|
11
10
|
ratings.push(reviewRating);
|
|
12
11
|
if (offer)
|
|
13
12
|
offersData.push(offer);
|
|
14
|
-
entities.push({ card, offer, reviewRating
|
|
13
|
+
entities.push({ card, offer, reviewRating });
|
|
15
14
|
}
|
|
16
15
|
const mainEntities = [];
|
|
17
16
|
for (const entity of entities) {
|
|
@@ -27,6 +26,7 @@ export class SearchStructuredDataFactory {
|
|
|
27
26
|
description,
|
|
28
27
|
'mainEntity': mainEntities
|
|
29
28
|
};
|
|
29
|
+
const paywallData = this.getPaywallData();
|
|
30
30
|
data.offers = this.constructOptionalPageOffers(offersData);
|
|
31
31
|
data.hasPart = this.constructOptionalPageParts(faqItems, paywallData);
|
|
32
32
|
data.breadcrumb = this.constructOptionalBreadcrumbs(breadcrumbs);
|
|
@@ -59,16 +59,7 @@ export class SearchStructuredDataFactory {
|
|
|
59
59
|
getOfferData(card) {
|
|
60
60
|
return Promise.resolve(undefined);
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
* Get the paywall data for a card.
|
|
64
|
-
* This method should be overridden by subclasses to provide the specific paywall logic.
|
|
65
|
-
* If no paywall data is available, return undefined and no paywall information will be added to the card.
|
|
66
|
-
*
|
|
67
|
-
* @param card
|
|
68
|
-
* @protected
|
|
69
|
-
*/
|
|
70
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
71
|
-
getPaywallData(card) {
|
|
62
|
+
getPaywallData() {
|
|
72
63
|
return undefined;
|
|
73
64
|
}
|
|
74
65
|
constructOptionalPageOffers(offersData) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studyportals/fawkes",
|
|
3
|
-
"version": "8.1.3-
|
|
3
|
+
"version": "8.1.3-3",
|
|
4
4
|
"description": "A package to centralize SEO related logic for SBLP and Sitemap Generator.",
|
|
5
5
|
"files": [
|
|
6
6
|
"./dist"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"publish-patch": "npm run prepare-deployment && npm version patch && npm publish",
|
|
18
18
|
"publish-minor": "npm run prepare-deployment && npm version minor && npm publish",
|
|
19
19
|
"prepare": "husky install",
|
|
20
|
-
"test": "
|
|
20
|
+
"test": "",
|
|
21
21
|
"test:dev": "vitest --coverage tests/programmes",
|
|
22
22
|
"lint": "eslint . --ext .ts",
|
|
23
23
|
"lint:fix": "eslint . --ext .ts --fix",
|