25 lines
809 B
TypeScript
25 lines
809 B
TypeScript
import type { Book, Chapter } from './book-types';
|
|
import { buildShareUrl } from './utm';
|
|
|
|
export function getShareText(chapter: Chapter, book: Book) {
|
|
const tags = book.viralTags.slice(0, 2).map((t) => `#${t}`).join(' ');
|
|
return `《${book.title}》· ${chapter.title}\n${chapter.hook}\n\n${tags}`;
|
|
}
|
|
|
|
export function getBookShareText(book: Pick<Book, 'title' | 'tagline' | 'viralTags'>) {
|
|
const tags = book.viralTags.slice(0, 3).map((t) => `#${t}`).join(' ');
|
|
return `📖《${book.title}》\n${book.tagline}\n\n${tags}`;
|
|
}
|
|
|
|
export function getChapterShareUrl(slug: string) {
|
|
return buildShareUrl(`/book/read#${slug}`, 'chapter');
|
|
}
|
|
|
|
export function getBookShareUrl() {
|
|
return buildShareUrl('/', 'cover');
|
|
}
|
|
|
|
export function getReadShareUrl() {
|
|
return buildShareUrl('/book/read', 'reader');
|
|
}
|