Skip to content

Commit

Permalink
chore(deps): bump @ircsignpost/signpost-base from 16.5.0 to 16.6.0 (#18)
Browse files Browse the repository at this point in the history
Bumps [@ircsignpost/signpost-base](https://github.com/unitedforukraine/signpost-base) from 16.5.0 to 16.6.0.
- [Commits](https://github.com/unitedforukraine/signpost-base/commits)

---
updated-dependencies:
- dependency-name: "@ircsignpost/signpost-base"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
dependabot[bot] authored Dec 13, 2023
1 parent 9cbeb7f commit 1637351
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 7 deletions.
2 changes: 2 additions & 0 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export const GOOGLE_ANALYTICS_IDS = [
// https://www.algolia.com/account/api-keys/
export const ALGOLIA_SEARCH_APP_ID = 'BWATZIXLX6';
export const ALGOLIA_SEARCH_API_KEY = '0d9093280e7b2bc2b6ca12ed4180fd0a';
export const ALGOLIA_SEARCH_API_KEY_WRITE =
process.env.ALGOLIA_SEARCH_API_KEY_WRITE ?? '';

// See README for more info on how to create indexes.
export const ALGOLIA_ARTICLE_INDEX_NAME =
Expand Down
1 change: 1 addition & 0 deletions next-sitemap.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const config = {
generateRobotsTxt: true,
exclude: [
'/*/articles/*',
'/*/services/*',
'/*/categories/*',
'/*/sections/*',
'/server-sitemap.xml',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@algolia/client-search": "^4.14.2",
"@changey/react-leaflet-markercluster": "^4.0.0-rc1",
"@directus/sdk": "^10.3.3",
"@ircsignpost/signpost-base": "16.5.0",
"@ircsignpost/signpost-base": "16.6.0",
"@next/env": "^12.2.4",
"@react-spring/web": "^9.5.4",
"@vercel/og": "^0.5.6",
Expand Down
1 change: 1 addition & 0 deletions pages/search-results-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export default function SearchResultsPage({
strings={strings}
siteUrl={siteUrl}
footerLinks={footerLinks}
servicesFilter={[1]}
signpostVersion={publicRuntimeConfig?.version}
cookieBanner={
<CookieBanner
Expand Down
2 changes: 2 additions & 0 deletions pages/server-sitemap.xml/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import { getSiteUrl } from '../../lib/url';
import * as article from '../articles/[article]';
import * as category from '../categories/[category]';
import * as section from '../sections/[section]';
import * as service from '../services/[service]';

export async function getServerSideProps(
ctx: GetServerSidePropsContext<ParsedUrlQuery, PreviewData>
) {
const allPaths: string[] = await Promise.all([
/* Put dynamic paths here and exclude them from next-sitemap.config.mjs */
article.getStringPaths(),
service.getStringPaths(),
category.getStringPaths(),
section.getStringPaths(),
]).then((results: string[][]) => results.flat());
Expand Down
65 changes: 63 additions & 2 deletions pages/services/[service].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ import {
getCategoriesWithSections,
getTranslationsFromDynamicContent,
} from '@ircsignpost/signpost-base/dist/src/zendesk';
import algoliasearch from 'algoliasearch/lite';
import { GetStaticProps } from 'next';
import getConfig from 'next/config';
import { useRouter } from 'next/router';
import React from 'react';

import {
ABOUT_US_ARTICLE_ID,
ALGOLIA_ARTICLE_INDEX_NAME,
ALGOLIA_QUERY_INDEX_NAME,
ALGOLIA_SEARCH_API_KEY_WRITE,
ALGOLIA_SEARCH_APP_ID,
CATEGORIES_TO_HIDE,
CATEGORY_ICON_NAMES,
DIRECTUS_AUTH_TOKEN,
Expand Down Expand Up @@ -269,8 +274,11 @@ export const getStaticProps: GetStaticProps = async ({
service.translations = serviceTranslated;

// If article does not exist, return an error.
if (!service || !service.translations.length ||
service?.country !== DIRECTUS_COUNTRY_ID) {
if (
!service ||
!service.translations.length ||
service?.country !== DIRECTUS_COUNTRY_ID
) {
const errorProps = await getErrorResponseProps(
Number(params?.article),
currentLocale,
Expand Down Expand Up @@ -305,6 +313,53 @@ export const getStaticProps: GetStaticProps = async ({
};
}

if (service) {
const body_safe = stripHtmlTags(service.description || '');
const title = service.name || '';
const query = title;
const id = service.id;
const locale = currentLocale;
const updated_at_iso = service.date_updated;
const translations = service.translations;
const category = { id: '1', title: 'Services' };
try {
const client = algoliasearch(
ALGOLIA_SEARCH_APP_ID,
ALGOLIA_SEARCH_API_KEY_WRITE
);
const record = {
objectID: id,
id,
title,
body_safe,
locale,
category,
updated_at_iso,
translations,
};
const index: any = client.initIndex(ALGOLIA_ARTICLE_INDEX_NAME);
await index.saveObject(record);
const indexquery: any = client.initIndex(ALGOLIA_QUERY_INDEX_NAME);
await indexquery.saveObject({
objectID: id,
id,
title,
body_safe,
locale,
category,
updated_at_iso,
translations,
query,
});
} catch (error) {
console.error(
`Error creating algolia index: ${
JSON.stringify(error) ?? 'Uknown error'
}`
);
}
}

service.description = serviceTranslated[0].description;
service.name = serviceTranslated[0].name;

Expand All @@ -329,3 +384,9 @@ export const getStaticProps: GetStaticProps = async ({
revalidate: REVALIDATION_TIMEOUT_SECONDS,
};
};

function stripHtmlTags(html: string): string {
const regex =
/<[^>]*>|&[^;]+;|<img\s+.*?>|<span\s+style="[^"]*">.*?<\/span>|&[A-Za-z]+;/g;
return html.replace(regex, '');
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -811,10 +811,10 @@
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==

"@ircsignpost/signpost-base@16.5.0":
version "16.5.0"
resolved "https://registry.yarnpkg.com/@ircsignpost/signpost-base/-/signpost-base-16.5.0.tgz#e38ac2a1f9db19b9d8349852703af6585e8b4dc9"
integrity sha512-bvj1o2dUWVpfXr0J9TFK61MHD+RACCDgib/eHeJ0pinpCDGXIX81G+1fC69DfMNLPPb+0yxjbKXZzSk8p/dROA==
"@ircsignpost/signpost-base@16.6.0":
version "16.6.0"
resolved "https://registry.yarnpkg.com/@ircsignpost/signpost-base/-/signpost-base-16.6.0.tgz#5004bba5aaa7af22ceb0e6b59425067971664389"
integrity sha512-Jkx8BJkdcXNsViJwD7HQKIkuFoYfJ44kmSecDOwz3smUSix3qVkKA9kcYa6ax0f1D5r2amsCG/CzJjScPE2F5g==

"@jridgewell/gen-mapping@^0.1.0":
version "0.1.1"
Expand Down

0 comments on commit 1637351

Please sign in to comment.