MCPcopy
hub / github.com/jwngr/sdow / Results

Function Results

website/src/components/Results.tsx:138–227  ·  view source on GitHub ↗
({
  paths,
  pagesById,
  sourcePageTitle,
  targetPageTitle,
  isSourceRedirected,
  isTargetRedirected,
  durationInSeconds,
})

Source from the content-addressed store, hash-verified

136 readonly isTargetRedirected: boolean;
137 readonly durationInSeconds: string;
138}> = ({
139 paths,
140 pagesById,
141 sourcePageTitle,
142 targetPageTitle,
143 isSourceRedirected,
144 isTargetRedirected,
145 durationInSeconds,
146}) => {
147 const sourcePageLink = (
148 <StyledTextLink
149 text={sourcePageTitle}
150 href={getWikipediaPageUrl(sourcePageTitle)}
151 target="_blank"
152 />
153 );
154
155 const targetPageLink = (
156 <StyledTextLink
157 text={targetPageTitle}
158 href={getWikipediaPageUrl(targetPageTitle)}
159 target="_blank"
160 />
161 );
162
163 // No paths found.
164 if (paths.length === 0) {
165 return (
166 <ResultsMessage>
167 <p>
168 <b>No path</b> exists from {sourcePageLink} to {targetPageLink}
169 </p>
170 <RedirectWarning
171 isSourceRedirected={isSourceRedirected}
172 isTargetRedirected={isTargetRedirected}
173 />
174 </ResultsMessage>
175 );
176 }
177
178 const degreesOfSeparation = paths[0].length - 1;
179 const pathOrPaths = paths.length === 1 ? 'path' : 'paths';
180 const degreeOrDegrees = degreesOfSeparation === 1 ? 'degree' : 'degrees';
181
182 const tweetText = `Found ${getNumberWithCommas(
183 paths.length
184 )} ${pathOrPaths} with ${degreesOfSeparation} ${degreeOrDegrees} of separation from "${sourcePageTitle}" to "${targetPageTitle}" on Six Degrees of Wikipedia!`;
185 const tweetUrl = `https://www.sixdegreesofwikipedia.com/?source=${encodeURIComponent(
186 sourcePageTitle
187 )}&target=${encodeURIComponent(targetPageTitle)}`;
188
189 return (
190 <>
191 <ResultsMessage>
192 <SnarkyContent degreesOfSeparation={degreesOfSeparation} />
193 <p>
194 Found{' '}
195 <b>

Callers

nothing calls this directly

Calls 2

getWikipediaPageUrlFunction · 0.90
getNumberWithCommasFunction · 0.90

Tested by

no test coverage detected