Add "similar" link for searching host name
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { Helmet } from 'react-helmet';
|
||||
import localForage from 'localforage';
|
||||
import { sourceLink, infoLine, ToggleDot } from './utils.js';
|
||||
import { sourceLink, similarLink, infoLine, ToggleDot } from './utils.js';
|
||||
import Latex from 'react-latex-next';
|
||||
import 'katex/dist/katex.min.css';
|
||||
|
||||
@@ -213,7 +213,7 @@ function Article({ cache }) {
|
||||
<h1>{story.title} <button className='copy-button' onClick={copyLink}>{copyButtonText}</button></h1>
|
||||
|
||||
<div className='info'>
|
||||
Source: {sourceLink(story)}
|
||||
Source: {sourceLink(story)} | {similarLink(story)}
|
||||
</div>
|
||||
|
||||
{infoLine(story)}
|
||||
|
||||
@@ -9,6 +9,13 @@ export const sourceLink = (story) => {
|
||||
return (<a className='source' href={url}>{host}</a>);
|
||||
};
|
||||
|
||||
export const similarLink = (story) => {
|
||||
const url = story.url || story.link;
|
||||
const urlObj = new URL(url);
|
||||
const host = urlObj.hostname.replace(/^www\./, '');
|
||||
return (<Link to={'/search?q="'+host+'"'} className='similar'>similar</Link>);
|
||||
};
|
||||
|
||||
export const infoLine = (story) =>
|
||||
<div className='info'>
|
||||
{story.score} points
|
||||
|
||||
Reference in New Issue
Block a user