diff --git a/.changeset/clever-mirrors-carry.md b/.changeset/clever-mirrors-carry.md new file mode 100644 index 0000000000..775c973229 --- /dev/null +++ b/.changeset/clever-mirrors-carry.md @@ -0,0 +1,5 @@ +--- +"nextjs-website": patch +--- + +fix reference in anchorEl for chatbot diff --git a/.changeset/curly-geese-attend.md b/.changeset/curly-geese-attend.md new file mode 100644 index 0000000000..ad96d36c8a --- /dev/null +++ b/.changeset/curly-geese-attend.md @@ -0,0 +1,6 @@ +--- +"gitbook-docs": patch +"nextjs-website": patch +--- + +Remove warnings from build output diff --git a/.changeset/fuzzy-bags-yawn.md b/.changeset/fuzzy-bags-yawn.md new file mode 100644 index 0000000000..507aeeb4ae --- /dev/null +++ b/.changeset/fuzzy-bags-yawn.md @@ -0,0 +1,5 @@ +--- +"nextjs-website": patch +--- + +Remove subtitle from banner link codec diff --git a/.changeset/fuzzy-buttons-sing.md b/.changeset/fuzzy-buttons-sing.md new file mode 100644 index 0000000000..d8f1ffa863 --- /dev/null +++ b/.changeset/fuzzy-buttons-sing.md @@ -0,0 +1,5 @@ +--- +"strapi-cms": minor +--- + +Remove subtitle attribute from bannerLink component diff --git a/.changeset/orange-beans-drop.md b/.changeset/orange-beans-drop.md new file mode 100644 index 0000000000..bac38c1251 --- /dev/null +++ b/.changeset/orange-beans-drop.md @@ -0,0 +1,5 @@ +--- +"nextjs-website": minor +--- + +Update url mapping for documentation diff --git a/apps/chatbot/.env.example b/apps/chatbot/.env.example index d69c203221..cf45f3da0b 100644 --- a/apps/chatbot/.env.example +++ b/apps/chatbot/.env.example @@ -13,6 +13,7 @@ CHB_WEBSITE_URL=... CHB_REDIS_INDEX_NAME=... CHB_LLAMAINDEX_INDEX_ID=... CHB_DOCUMENTATION_DIR=... +CHB_USE_PRESIDIO=... CHB_GOOGLE_API_KEY=... CHB_PROVIDER=... CHB_MODEL_ID=... @@ -25,3 +26,4 @@ CHB_ENGINE_USE_ASYNC=True CHB_ENGINE_USE_STREAMING=... CHB_QUERY_TABLE_PREFIX=chatbot-local CHB_DYNAMODB_URL=http://locahost:8080 +CHB_USE_PRESIDIO=True diff --git a/apps/chatbot/config/prompts.yaml b/apps/chatbot/config/prompts.yaml index daf7b34161..61b4f4f51e 100644 --- a/apps/chatbot/config/prompts.yaml +++ b/apps/chatbot/config/prompts.yaml @@ -12,7 +12,6 @@ qa_prompt_str: | - the answer must be clear, non-redundant, and have not repeated sentences. - the answer must not include the query. - If your answer is based on this retrieved context, include a "Rif" section at the end of the response, listing the titles and filenames from the source nodes used. If no context is used, do not include a reference. - - the answer must be with the same language of the query. -------------------- Output Examples: Query: Cos'รจ il nodo dei pagamenti? @@ -38,7 +37,14 @@ qa_prompt_str: | -------------------- Task: Given the query: {query_str} - Answer the query according to the `Chatbot Policy` listed above. + + Reply to the user following these two steps: + Step 1: + Pay great attention in detail on the query's language and determine if it is formulated in Italian, English, Spanish, French, German, Greek, Croatian, or Slovenian ('yes' or 'no'). + Step 2: + If Step 1 returns 'yes': reply always in Italian, regardless of the input language, according to the `Chatbot Policy` listed above. + Otherwise: reply you cannot speak that language and ask for a new query written in an accepted language. + Answer: diff --git a/apps/chatbot/docker/compose.yaml b/apps/chatbot/docker/compose.yaml index e720460e45..349c715027 100644 --- a/apps/chatbot/docker/compose.yaml +++ b/apps/chatbot/docker/compose.yaml @@ -32,6 +32,7 @@ services: image: redis/redis-stack:7.2.0-v13 ports: - "6379:6379" + - "8001:8001" networks: - ntw diff --git a/apps/chatbot/src/modules/chatbot.py b/apps/chatbot/src/modules/chatbot.py index a187968503..5b361e949d 100644 --- a/apps/chatbot/src/modules/chatbot.py +++ b/apps/chatbot/src/modules/chatbot.py @@ -16,10 +16,7 @@ from src.modules.presidio import PresidioPII -AWS_S3_BUCKET = os.getenv("CHB_AWS_S3_BUCKET") -ITALIAN_THRESHOLD = 0.85 -NUM_MIN_WORDS_QUERY = 3 -NUM_MIN_REFERENCES = 1 +USE_PRESIDIO = True if os.getenv("CHB_USE_PRESIDIO", "True") == "True" else False RESPONSE_TYPE = Union[ Response, StreamingResponse, AsyncStreamingResponse, PydanticResponse ] @@ -36,7 +33,9 @@ def __init__( self.params = params self.prompts = prompts - self.pii = PresidioPII(config=params["config_presidio"]) + if USE_PRESIDIO: + self.pii = PresidioPII(config=params["config_presidio"]) + self.model = get_llm() self.embed_model = get_embed_model() self.index = load_automerging_index_redis( @@ -111,6 +110,9 @@ def _get_response_str(self, engine_response: RESPONSE_TYPE) -> str: """ else: response_str = self._unmask_reference(response_str, nodes) + + if "Step 2:" in response_str: + response_str = response_str.split("Step 2:")[1].strip() return response_str @@ -142,7 +144,10 @@ def _unmask_reference(self, response_str: str, nodes) -> str: def mask_pii(self, message: str) -> str: - return self.pii.mask_pii(message) + if USE_PRESIDIO: + return self.pii.mask_pii(message) + else: + return message def generate(self, query_str: str) -> str: diff --git a/apps/chatbot/src/modules/presidio.py b/apps/chatbot/src/modules/presidio.py index 7de5560873..65e7f114e1 100644 --- a/apps/chatbot/src/modules/presidio.py +++ b/apps/chatbot/src/modules/presidio.py @@ -12,7 +12,7 @@ # see supported entities by Presidio with their description at: https://microsoft.github.io/presidio/supported_entities/ -ENTITIES = [ +GLOBAL_ENTITIES = [ "CREDIT_CARD", "CRYPTO", "DATE_TIME", @@ -23,21 +23,16 @@ "LOCATION", "PERSON", "PHONE_NUMBER", - "MEDICAL_LICENSE", + "MEDICAL_LICENSE" +] + +IT_ENTITIES = [ "IT_FISCAL_CODE", "IT_DRIVER_LICENSE", "IT_VAT_CODE", "IT_PASSPORT", "IT_IDENTITY_CARD", - "IT_PHYSICAL_ADDRESS", # this is a custom entity added to the analyzer registry - # "ES_NIF", - # "ES_NIE", - # "US_BANK_NUMBER", - # "US_DRIVER_LICENSE", - # "US_ITIN", - # "US_PASSPORT", - # "US_SSN", - # "UK_NHS" + "IT_PHYSICAL_ADDRESS" ] ALLOW_LIST = [ @@ -102,9 +97,10 @@ def __init__( analyzer_threshold: float = 0.4 ): self.config = config + self.languages = [item["lang_code"] for item in config["models"]] self.entity_mapping = entity_mapping self.mapping = mapping - self.entities = entities if entities else ENTITIES + self.entities = entities if entities else GLOBAL_ENTITIES self.analyzer_threshold = analyzer_threshold if isinstance(self.config, (Path, str)): @@ -117,7 +113,7 @@ def __init__( self.nlp_engine = nlp_engine self.analyzer = AnalyzerEngine( nlp_engine = self.nlp_engine, - supported_languages = ["it", "en"], # "es", "fr", "de" + supported_languages = self.languages, default_score_threshold = analyzer_threshold ) self._add_italian_physical_address_entity() @@ -136,7 +132,7 @@ def detect_language(self, text: str) -> str: detected_languages = detect_langs(text) lang_list = [] for detected_lang in detected_languages: - if detected_lang.lang in ["it", "en", "es", "fr", "de"]: + if detected_lang.lang in self.languages: lang_list.append(detected_lang.lang) if not lang_list: @@ -145,7 +141,7 @@ def detect_language(self, text: str) -> str: elif "it" in lang_list: lang = "it" else: - lang = "en" # lang_list[0].lang + lang = lang_list[0] except: logging.warning("No detected language.") lang = "it" @@ -160,7 +156,7 @@ def detect_pii(self, text: str) -> List[RecognizerResult]: results = self.analyzer.analyze( text=text, language=lang, - entities=self.entities, + entities=self.entities + IT_ENTITIES if lang == "it" else self.entities, allow_list=ALLOW_LIST ) diff --git a/apps/nextjs-website/src/_contents/products.ts b/apps/nextjs-website/src/_contents/products.ts index 398dcbb44c..8af34d91c1 100644 --- a/apps/nextjs-website/src/_contents/products.ts +++ b/apps/nextjs-website/src/_contents/products.ts @@ -97,7 +97,7 @@ export const spaceToPrefixMap = pipe( /** * Contains the mapping between the docs.pagopa.it url and the developer portal url. */ -export const urlReplacesMap: { readonly [url: string]: string } = { +export const staticUrlReplaceMap: { readonly [url: string]: string } = { // App IO 'https://docs.pagopa.it/io-guida-tecnica-1.3/': '/app-io/guides/io-guida-tecnica/v1.3', diff --git a/apps/nextjs-website/src/app/[productSlug]/guides/[...productGuidePage]/page.tsx b/apps/nextjs-website/src/app/[productSlug]/guides/[...productGuidePage]/page.tsx index fed4e565cd..e8d8e3b9de 100644 --- a/apps/nextjs-website/src/app/[productSlug]/guides/[...productGuidePage]/page.tsx +++ b/apps/nextjs-website/src/app/[productSlug]/guides/[...productGuidePage]/page.tsx @@ -4,11 +4,7 @@ import ProductLayout, { import { getGuide, getProductGuidePath } from '@/lib/api'; import { Product } from '@/lib/types/product'; import React from 'react'; -import { - gitBookPagesWithTitle, - spaceToPrefixMap, - urlReplacesMap, -} from '@/_contents/products'; +import { gitBookPagesWithTitle, spaceToPrefixMap } from '@/_contents/products'; import { ParseContentConfig } from 'gitbook-docs/parseContent'; import { Metadata } from 'next'; import { @@ -17,7 +13,7 @@ import { } from '@/helpers/metadata.helpers'; import GitBookTemplate from '@/components/templates/GitBookTemplate/GitBookTemplate'; import { productPageToBreadcrumbs } from '@/helpers/breadcrumbs.helpers'; -import { getGuidesProps } from '@/lib/cmsApi'; +import { getGuidesProps, getUrlReplaceMapProps } from '@/lib/cmsApi'; import { generateStructuredDataScripts } from '@/helpers/generateStructuredDataScripts.helpers'; import { breadcrumbItemByProduct, @@ -81,7 +77,7 @@ const Page = async ({ params }: { params: Params }) => { params?.productSlug, params?.productGuidePage ?? [''] ); - + const urlReplaceMap = await getUrlReplaceMapProps(); const { product, page, guide, version, versions, source, bannerLinks, seo } = guideProps; const props: ProductGuidePageProps = { @@ -98,7 +94,7 @@ const Page = async ({ params }: { params: Params }) => { assetsPrefix: source.assetsPrefix, gitBookPagesWithTitle, spaceToPrefix: spaceToPrefixMap, - urlReplaces: urlReplacesMap, + urlReplaces: urlReplaceMap, }, }; diff --git a/apps/nextjs-website/src/app/[productSlug]/tutorials/[...productTutorialPage]/page.tsx b/apps/nextjs-website/src/app/[productSlug]/tutorials/[...productTutorialPage]/page.tsx index 5645e925e6..72d47f22ce 100644 --- a/apps/nextjs-website/src/app/[productSlug]/tutorials/[...productTutorialPage]/page.tsx +++ b/apps/nextjs-website/src/app/[productSlug]/tutorials/[...productTutorialPage]/page.tsx @@ -9,11 +9,7 @@ import { import { Product } from '@/lib/types/product'; import GitBookContent from '@/components/organisms/GitBookContent/GitBookContent'; import { Box } from '@mui/material'; -import { - gitBookPagesWithTitle, - spaceToPrefixMap, - urlReplacesMap, -} from '@/_contents/products'; +import { gitBookPagesWithTitle, spaceToPrefixMap } from '@/_contents/products'; import { ParseContentConfig } from 'gitbook-docs/parseContent'; import { Metadata } from 'next'; import { @@ -34,6 +30,7 @@ import { breadcrumbItemByProduct, productToBreadcrumb, } from '@/helpers/structuredData.helpers'; +import { getUrlReplaceMapProps } from '@/lib/cmsApi'; type Params = { productSlug: string; @@ -124,6 +121,7 @@ const Page = async ({ params }: { params: Params }) => { ); } + const urlReplaceMap = await getUrlReplaceMapProps(); const tutorialProps = await getStaticTutorial(productSlug, [tutorialPath]); const { product, page, bannerLinks, source, relatedLinks } = tutorialProps; const props: ProductTutorialPageProps = { @@ -137,7 +135,7 @@ const Page = async ({ params }: { params: Params }) => { assetsPrefix: source.assetsPrefix, gitBookPagesWithTitle, spaceToPrefix: spaceToPrefixMap, - urlReplaces: urlReplacesMap, + urlReplaces: urlReplaceMap, }, }; diff --git a/apps/nextjs-website/src/app/solutions/[solutionSlug]/[...solutionSubPathSlugs]/page.tsx b/apps/nextjs-website/src/app/solutions/[solutionSlug]/[...solutionSubPathSlugs]/page.tsx index 213f3b3cc4..b833b9a97c 100644 --- a/apps/nextjs-website/src/app/solutions/[solutionSlug]/[...solutionSubPathSlugs]/page.tsx +++ b/apps/nextjs-website/src/app/solutions/[solutionSlug]/[...solutionSubPathSlugs]/page.tsx @@ -1,16 +1,12 @@ import React from 'react'; -import { - gitBookPagesWithTitle, - spaceToPrefixMap, - urlReplacesMap, -} from '@/_contents/products'; +import { gitBookPagesWithTitle, spaceToPrefixMap } from '@/_contents/products'; import { Metadata } from 'next'; import { makeMetadata } from '@/helpers/metadata.helpers'; import { getSolutionDetail, getSolutionSubPaths } from '@/lib/api'; import GitBookTemplate from '@/components/templates/GitBookTemplate/GitBookTemplate'; import { pageToBreadcrumbs } from '@/helpers/breadcrumbs.helpers'; import { ParseContentConfig } from 'gitbook-docs/parseContent'; -import { getSolutionsProps } from '@/lib/cmsApi'; +import { getSolutionsProps, getUrlReplaceMapProps } from '@/lib/cmsApi'; import { SolutionTemplateProps } from '@/components/templates/SolutionTemplate/SolutionTemplate'; import { generateStructuredDataScripts } from '@/helpers/generateStructuredDataScripts.helpers'; import { getItemFromPaths } from '@/helpers/structuredData.helpers'; @@ -64,6 +60,7 @@ const Page = async ({ params }: { params: Params }) => { params?.solutionSubPathSlugs ); + const urlReplaceMap = await getUrlReplaceMapProps(); if (!solutionProps) { return null; } @@ -79,7 +76,7 @@ const Page = async ({ params }: { params: Params }) => { assetsPrefix: source.assetsPrefix, gitBookPagesWithTitle, spaceToPrefix: spaceToPrefixMap, - urlReplaces: urlReplacesMap, + urlReplaces: urlReplaceMap, }, }; diff --git a/apps/nextjs-website/src/components/atoms/MobileUserInfo/MobileUserInfo.tsx b/apps/nextjs-website/src/components/atoms/MobileUserInfo/MobileUserInfo.tsx index d381cfdcc6..c11a5805ee 100644 --- a/apps/nextjs-website/src/components/atoms/MobileUserInfo/MobileUserInfo.tsx +++ b/apps/nextjs-website/src/components/atoms/MobileUserInfo/MobileUserInfo.tsx @@ -8,7 +8,6 @@ import Link from 'next/link'; import { useTranslations } from 'next-intl'; import { usePathname, useRouter } from 'next/navigation'; import { MobileSiteHeaderStyledTreeItem } from '@/components/molecules/MobileSiteHeader/MobileSiteHeader'; -import { ButtonNaked } from '@pagopa/mui-italia'; type MobileUserInfoProps = { // eslint-disable-next-line functional/no-return-void diff --git a/apps/nextjs-website/src/components/organisms/ChatbotLayout/ChatbotLayout.tsx b/apps/nextjs-website/src/components/organisms/ChatbotLayout/ChatbotLayout.tsx index f9f3ac93b9..91bbe13fb7 100644 --- a/apps/nextjs-website/src/components/organisms/ChatbotLayout/ChatbotLayout.tsx +++ b/apps/nextjs-website/src/components/organisms/ChatbotLayout/ChatbotLayout.tsx @@ -35,17 +35,18 @@ const ChatbotLayout = ({ }: ChatbotLayoutProps) => { const t = useTranslations(); const { palette } = useTheme(); - const [anchorEl, setAnchorEl] = React.useState( - null + const ref = React.useRef(); + const [anchorEl, setAnchorEl] = React.useState( + undefined ); - const handleClick = (event: React.MouseEvent) => { - setAnchorEl(event.currentTarget); + const handleClick = () => { + setAnchorEl(ref.current); return null; }; const handleClose = () => { - setAnchorEl(null); + setAnchorEl(undefined); }; const open = Boolean(anchorEl); @@ -53,6 +54,7 @@ const ChatbotLayout = ({ return ( { } }; +export const getUrlReplaceMapProps = async () => { + const { + config: { FETCH_FROM_STRAPI: fetchFromStrapi }, + } = buildEnv; + + if (fetchFromStrapi) { + const urlReplaceMap = await fetchUrlReplaceMap(buildEnv); + return { ...staticUrlReplaceMap, ...makeUrlReplaceMap(urlReplaceMap) }; + } + return staticUrlReplaceMap; +}; + export const getApiDataListPagesProps = async () => { const { config: { FETCH_FROM_STRAPI: fetchFromStrapi }, diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/urlReplaceMap.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/urlReplaceMap.test.ts index 14436aaa42..218ef4e89a 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/urlReplaceMap.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/urlReplaceMap.test.ts @@ -1,8 +1,8 @@ -import { UrlReplaceMapCodec } from '../codecs/UrlReplaceMapCodec'; import * as Either from 'fp-ts/lib/Either'; +import { pipe } from 'fp-ts/lib/function'; +import { UrlReplaceMapCodec } from '../codecs/UrlReplaceMapCodec'; import { productJson } from './fixtures/product'; import { makeUrlReplaceMap } from '../makeProps/makeUrlReplaceMap'; -import { pipe } from 'fp-ts/lib/function'; import { mediaRasterJson } from './fixtures/media'; const strapiResponse = { @@ -73,7 +73,7 @@ describe('UrlReplaceMapCodec', () => { const urlReplaceMap = makeUrlReplaceMap(result!); expect(urlReplaceMap).toEqual({ - aaaa: 'firma-con-io/guides/aaaa/2', + aaaa: '/firma-con-io/guides/aaaa/2', }); }); }); diff --git a/apps/nextjs-website/src/lib/strapi/codecs/BannerLinkCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/BannerLinkCodec.ts index b7c03652bd..fe7073482c 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/BannerLinkCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/BannerLinkCodec.ts @@ -6,10 +6,9 @@ import { MediaCodec } from './MediaCodec'; export const BannerLinkCodec = t.strict({ id: t.number, title: t.union([NullToUndefinedCodec, t.string]), - subtitle: t.union([NullToUndefinedCodec, t.string]), content: t.union([NullToUndefinedCodec, BlocksContentCodec]), icon: t.strict({ data: MediaCodec }), theme: t.union([t.literal('light'), t.literal('dark')]), }); -export type BannerLink = t.TypeOf; +export type StrapiBannerLink = t.TypeOf; diff --git a/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts index 084879ebe6..c133ce9842 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts @@ -103,6 +103,6 @@ export const ProductsCodec = t.strict({ data: t.array(ProductCodec), }); -export type BaseProduct = t.TypeOf; -export type Product = t.TypeOf; -export type Products = t.TypeOf; +export type StrapiBaseProduct = t.TypeOf; +export type StrapiProduct = t.TypeOf; +export type StrapiProducts = t.TypeOf; diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchUrlReplaceMap.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchUrlReplaceMap.ts index 5d163c2fce..1db7b7298f 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchUrlReplaceMap.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchUrlReplaceMap.ts @@ -4,17 +4,25 @@ import qs from 'qs'; const makeStrapiUrlReplaceMapPopulate = () => qs.stringify({ - populate: [ - 'urlToGuide.guide.*', - 'urlToGuide.guide.image', - 'urlToGuide.guide.mobileImage', - 'urlToGuide.guide.listItems', - 'urlToGuide.guide.product.*', - 'urlToGuide.guide.versions.*', - 'urlToGuide.guide.seo.*', - 'urlToGuide.guide.product.bannerLinks.*', - 'urlToGuide.guide.product.bannerLinks.icon', - ], + populate: { + urlToGuide: { + populate: { + guide: { + populate: [ + 'image', + 'mobileImage', + 'listItems', + 'versions', + 'bannerLinks.icon', + 'seo', + 'seo.metaSocial.image', + 'product.logo', + 'product.bannerLinks.icon', + ], + }, + }, + }, + }, }); export const fetchUrlReplaceMap = fetchFromStrapi( diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeBannerLink.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeBannerLink.ts index 59229e3175..8429cc840e 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeBannerLink.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeBannerLink.ts @@ -1,8 +1,8 @@ import { BannerLinkProps } from '@/components/atoms/BannerLink/BannerLink'; -import { BannerLink } from '@/lib/strapi/codecs/BannerLinkCodec'; +import { StrapiBannerLink } from '@/lib/strapi/codecs/BannerLinkCodec'; export function makeBannerLinkProps( - strapiBannerLink: BannerLink + strapiBannerLink: StrapiBannerLink ): BannerLinkProps { return { content: strapiBannerLink.content, diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeOverviews.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeOverviews.ts index aba5a98205..42753f457b 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeOverviews.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeOverviews.ts @@ -33,7 +33,6 @@ export function makeOverviewsProps( items: attributes.features.items.map((item) => ({ iconUrl: item.icon.data?.attributes.url, - subtitle: item.subtitle, content: item.content, title: item.title || '', })) || [], diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts index a9db81004f..e9b35b1a86 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts @@ -1,14 +1,15 @@ import { products } from '@/_contents/products'; import { - Products, - Product as ApiProduct, - BaseProduct, + StrapiProducts, + StrapiProduct, + StrapiBaseProduct, } from '../codecs/ProductCodec'; import { Product } from '../../types/product'; import { makeBannerLinkProps } from '@/lib/strapi/makeProps/makeBannerLink'; export function mergeProductWithStaticContent( - attributes: Partial & BaseProduct['attributes'] + attributes: Partial & + StrapiBaseProduct['attributes'] ): Product { const staticProduct = products.find((product) => product.slug === attributes.slug) || products[0]; @@ -21,7 +22,7 @@ export function mergeProductWithStaticContent( } export function makeProductsProps( - products: Products, + products: StrapiProducts, staticProducts: ReadonlyArray ): ReadonlyArray { return [ diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeUrlReplaceMap.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeUrlReplaceMap.ts index 764aa09a07..fdeb5bdce8 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeUrlReplaceMap.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeUrlReplaceMap.ts @@ -5,15 +5,14 @@ export type UrlReplaceMap = Record; export function makeUrlReplaceMap( urlReplacemap: StrapiUrlReplaceMap ): UrlReplaceMap { - const map = urlReplacemap.data.attributes.urlToGuide.reduce((map, obj) => { + return urlReplacemap.data.attributes.urlToGuide.reduce((map, obj) => { return { ...map, - [obj.url]: `${ + [obj.url]: `/${ obj.guide.data?.attributes.product.data.attributes.slug }/guides/${obj.guide.data?.attributes.slug}${ obj.version ? `/${obj.version}` : '' }`, }; }, {} as UrlReplaceMap); - return map; } diff --git a/apps/strapi-cms/src/components/common/banner-link.json b/apps/strapi-cms/src/components/common/banner-link.json index d046f1397b..ed4cca6da5 100644 --- a/apps/strapi-cms/src/components/common/banner-link.json +++ b/apps/strapi-cms/src/components/common/banner-link.json @@ -10,9 +10,6 @@ "title": { "type": "string" }, - "subtitle": { - "type": "string" - }, "content": { "type": "blocks" }, diff --git a/packages/gitbook-docs/src/markdoc/schema/code.ts b/packages/gitbook-docs/src/markdoc/schema/code.ts index 78c720361e..25e00fbd00 100644 --- a/packages/gitbook-docs/src/markdoc/schema/code.ts +++ b/packages/gitbook-docs/src/markdoc/schema/code.ts @@ -43,6 +43,7 @@ export const code: Schema = { 'CodeBlock', { ...Object.fromEntries( + // eslint-disable-next-line @typescript-eslint/no-unused-vars Object.entries(attrs).filter(([_, value]) => value !== null) ), ...fenceAttr, diff --git a/packages/gitbook-docs/src/markdoc/schema/swagger.ts b/packages/gitbook-docs/src/markdoc/schema/swagger.ts index c14cb546aa..b0e13d50c9 100644 --- a/packages/gitbook-docs/src/markdoc/schema/swagger.ts +++ b/packages/gitbook-docs/src/markdoc/schema/swagger.ts @@ -1,4 +1,4 @@ -import Markdoc, { Schema } from '@markdoc/markdoc'; +import Markdoc, { RenderableTreeNode, Schema } from '@markdoc/markdoc'; import { SrcAttr } from '../attributes'; export type SwaggerProps = { @@ -19,9 +19,10 @@ export const swagger: Schema = { baseUrl: { type: String }, }, transform: (node, config) => { - const attrs = node.transformAttributes(config); - const children = node.transformChildren(config); - return new Markdoc.Tag('Swagger', attrs, children); + const attrs: Record = node.transformAttributes(config); + const children: readonly RenderableTreeNode[] = + node.transformChildren(config); + return new Markdoc.Tag('Swagger', attrs, [...children]); }, };