@studyportals/fawkes 8.3.0 → 8.4.0

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.
@@ -3,11 +3,12 @@ import { SortingOptions } from '../../../enums/SortingOptions';
3
3
  import { OrganisationsSeoIndexabilityPolicy } from '../../../organisations/policies/OrganisationsSeoIndexabilityPolicy';
4
4
  import { SingleValueSelectedForFilterRule } from '../../../common/rules/SingleValueSelectedForFilterRule';
5
5
  import { OnlyFiltersSelectedRule } from '../../../common/rules/OnlyFiltersSelectedRule';
6
+ import { ExcludeByIdForCitiesRule } from '../../../organisations/rules/ExcludeByIdForCitiesRule';
6
7
  export declare class CountryAreaCity extends OrganisationsSeoIndexabilityPolicy {
7
8
  readonly name: string;
8
9
  readonly description: string;
9
10
  protected readonly sortingOption = SortingOptions.OUR_PICKS;
10
- protected readonly baseRules: (SingleValueSelectedForFilterRule | OnlyFiltersSelectedRule)[];
11
+ protected readonly baseRules: (SingleValueSelectedForFilterRule | OnlyFiltersSelectedRule | ExcludeByIdForCitiesRule)[];
11
12
  protected generateUrls(): Promise<string[]>;
12
13
  get filterCombination(): FilterCombinations;
13
14
  }
@@ -5,6 +5,7 @@ import { OrganisationsSeoIndexabilityPolicy } from '../../../organisations/polic
5
5
  import { SingleValueSelectedForFilterRule } from '../../../common/rules/SingleValueSelectedForFilterRule';
6
6
  import { OnlyFiltersSelectedRule } from '../../../common/rules/OnlyFiltersSelectedRule';
7
7
  import { CityPresenter } from '../../../presenters/CityPresenter';
8
+ import { ExcludeByIdForCitiesRule } from '../../../organisations/rules/ExcludeByIdForCitiesRule';
8
9
  export class CountryAreaCity extends OrganisationsSeoIndexabilityPolicy {
9
10
  name = 'Country Area City Policy';
10
11
  description = 'Controls indexing of pages filtered by geographic cities and areas, ensuring only SEO-valuable regional content with sufficient search volume is indexed.';
@@ -13,7 +14,8 @@ export class CountryAreaCity extends OrganisationsSeoIndexabilityPolicy {
13
14
  new SingleValueSelectedForFilterRule(FilterKey.CITY),
14
15
  new SingleValueSelectedForFilterRule(FilterKey.COUNTRY),
15
16
  new SingleValueSelectedForFilterRule(FilterKey.AREA),
16
- new OnlyFiltersSelectedRule([FilterKey.CITY, FilterKey.COUNTRY, FilterKey.AREA])
17
+ new OnlyFiltersSelectedRule([FilterKey.CITY, FilterKey.COUNTRY, FilterKey.AREA]),
18
+ new ExcludeByIdForCitiesRule(FilterKey.CITY)
17
19
  ];
18
20
  async generateUrls() {
19
21
  const cityFragments = await CityPresenter
@@ -3,11 +3,12 @@ import { SortingOptions } from '../../../enums/SortingOptions';
3
3
  import { OrganisationsSeoIndexabilityPolicy } from '../../../organisations/policies/OrganisationsSeoIndexabilityPolicy';
4
4
  import { SingleValueSelectedForFilterRule } from '../../../common/rules/SingleValueSelectedForFilterRule';
5
5
  import { OnlyFiltersSelectedRule } from '../../../common/rules/OnlyFiltersSelectedRule';
6
+ import { ExcludeByIdForCitiesRule } from '../../../organisations/rules/ExcludeByIdForCitiesRule';
6
7
  export declare class CountryCity extends OrganisationsSeoIndexabilityPolicy {
7
8
  readonly name: string;
8
9
  readonly description: string;
9
10
  protected readonly sortingOption = SortingOptions.OUR_PICKS;
10
- protected readonly baseRules: (SingleValueSelectedForFilterRule | OnlyFiltersSelectedRule)[];
11
+ protected readonly baseRules: (SingleValueSelectedForFilterRule | OnlyFiltersSelectedRule | ExcludeByIdForCitiesRule)[];
11
12
  protected generateUrls(): Promise<string[]>;
12
13
  get filterCombination(): FilterCombinations;
13
14
  }
@@ -5,6 +5,7 @@ import { OrganisationsSeoIndexabilityPolicy } from '../../../organisations/polic
5
5
  import { CityPresenter } from '../../../presenters/CityPresenter';
6
6
  import { SingleValueSelectedForFilterRule } from '../../../common/rules/SingleValueSelectedForFilterRule';
7
7
  import { OnlyFiltersSelectedRule } from '../../../common/rules/OnlyFiltersSelectedRule';
8
+ import { ExcludeByIdForCitiesRule } from '../../../organisations/rules/ExcludeByIdForCitiesRule';
8
9
  export class CountryCity extends OrganisationsSeoIndexabilityPolicy {
9
10
  name = 'Country City Policy';
10
11
  description = 'Controls indexing of pages filtered by geographic cities, ensuring only SEO-valuable regional content with sufficient search volume is indexed.';
@@ -12,7 +13,8 @@ export class CountryCity extends OrganisationsSeoIndexabilityPolicy {
12
13
  baseRules = [
13
14
  new SingleValueSelectedForFilterRule(FilterKey.CITY),
14
15
  new SingleValueSelectedForFilterRule(FilterKey.COUNTRY),
15
- new OnlyFiltersSelectedRule([FilterKey.CITY, FilterKey.COUNTRY])
16
+ new OnlyFiltersSelectedRule([FilterKey.CITY, FilterKey.COUNTRY]),
17
+ new ExcludeByIdForCitiesRule(FilterKey.CITY)
16
18
  ];
17
19
  async generateUrls() {
18
20
  const cityFragments = await CityPresenter
@@ -0,0 +1,13 @@
1
+ import { IRule } from "../../common/IRule";
2
+ import { ISearchDependencies } from "../../common/ISearchDependencies";
3
+ import { FilterKey } from "@studyportals/search-filters/server-side";
4
+ import { FilterKeyValuesMap } from "../../../sitemap-generator-seo";
5
+ export declare class ExcludeByIdForCitiesRule implements IRule {
6
+ private readonly filterKey;
7
+ private excludedIds;
8
+ constructor(filterKey: FilterKey);
9
+ forSearch(dependencies: ISearchDependencies): Promise<boolean>;
10
+ forSitemapGenerator(filterKeyValues: FilterKeyValuesMap): Promise<boolean>;
11
+ getName(): string;
12
+ getDescription(): string;
13
+ }
@@ -0,0 +1,31 @@
1
+ import { FilterKey } from "@studyportals/search-filters/server-side";
2
+ export class ExcludeByIdForCitiesRule {
3
+ filterKey;
4
+ excludedIds;
5
+ constructor(filterKey) {
6
+ this.filterKey = filterKey;
7
+ // Exclude city with ID 532 (Washington D.C.)
8
+ this.excludedIds = ['532'];
9
+ }
10
+ async forSearch(dependencies) {
11
+ const selectedCities = dependencies.seoInfoBase.getFilterOptionValueBy(this.filterKey, dependencies.filterState);
12
+ if (!selectedCities || selectedCities.trim() === '') {
13
+ return Promise.resolve(false);
14
+ }
15
+ return Promise.resolve(!this.excludedIds.includes(selectedCities));
16
+ }
17
+ async forSitemapGenerator(filterKeyValues) {
18
+ const cities = filterKeyValues.get(FilterKey.CITY);
19
+ if (cities && cities.length > 0) {
20
+ const filteredCities = cities.filter(city => !this.excludedIds.includes(city));
21
+ return Promise.resolve(filteredCities.length > 0);
22
+ }
23
+ return Promise.resolve(true);
24
+ }
25
+ getName() {
26
+ return 'ExcludeByIdForCitiesRule';
27
+ }
28
+ getDescription() {
29
+ return `This rule excludes specific city IDs from the search results. (${this.excludedIds.join(", ")})`;
30
+ }
31
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studyportals/fawkes",
3
- "version": "8.3.0",
3
+ "version": "8.4.0",
4
4
  "description": "A package to centralize SEO related logic for SBLP and Sitemap Generator.",
5
5
  "files": [
6
6
  "./dist"