mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(home): clarify 5chan is serverless app, use current hostname for share links
- Homepage infobox: merged copy into single line explaining app nature and download link - Share links (Copy direct link): use window.location.origin instead of hardcoded 5chan.app - Settings version link: use current origin - FAQ: add 'Is 5chan just this website?' entry under Basics - Remove pleb.bz from CHAN_5_HOSTNAMES
This commit is contained in:
@@ -19,6 +19,17 @@ export const isValidURL = (url: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
const CHAN_5_HOSTNAMES = ['5chan.app', '5chan.eth.limo', '5chan.eth.link', '5chan.eth.sucks', '5chan.netlify.app'];
|
||||
|
||||
function getShareBaseUrl(): string {
|
||||
const { protocol, hostname, origin } = window.location;
|
||||
if ((protocol === 'https:' || protocol === 'http:') && hostname !== 'localhost' && hostname !== '127.0.0.1') {
|
||||
return origin;
|
||||
}
|
||||
// Electron / Capacitor / local dev fallback
|
||||
return `https://${CHAN_5_HOSTNAMES[0]}`;
|
||||
}
|
||||
|
||||
export type ShareLinkType = 'thread' | 'catalog';
|
||||
|
||||
// Copies a share link to clipboard for a board, thread, description, or rules page
|
||||
@@ -29,17 +40,15 @@ export async function copyShareLinkToClipboard(boardIdentifier: string, linkType
|
||||
if (!cid) {
|
||||
throw new Error('copyShareLinkToClipboard: thread links require a cid');
|
||||
}
|
||||
const shareLink = `https://5chan.app/#/${boardIdentifier}/thread/${cid}`;
|
||||
const shareLink = `${getShareBaseUrl()}/#/${boardIdentifier}/thread/${cid}`;
|
||||
await copyToClipboard(shareLink);
|
||||
return;
|
||||
}
|
||||
|
||||
const shareLink = `https://5chan.app/#/${boardIdentifier}/${linkType}`;
|
||||
const shareLink = `${getShareBaseUrl()}/#/${boardIdentifier}/${linkType}`;
|
||||
await copyToClipboard(shareLink);
|
||||
}
|
||||
|
||||
const CHAN_5_HOSTNAMES = ['pleb.bz', '5chan.app', '5chan.eth.limo', '5chan.eth.link', '5chan.eth.sucks', '5chan.netlify.app'];
|
||||
|
||||
// Check if a URL is a valid 5chan link that should be handled internally
|
||||
export const is5chanLink = (url: string): boolean => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user