1export default async function handleRequest(request: Request): Promise<Response> {
2// this is a function called handleRequest that is exported for use elsewhere and accepts one input
3const { url } = await request.json();
4// the variable url cannot be changed and to the code to wait until the HTTP data is read and and turned into JSON
ValTownForNotionresets1 match
7});
89export default async function(interval: Interval) {
10const subdomain = "valtownfornotion";
11const items = await blob.list(subdomain);
ValTownForNotionnotionHelpers.ts20 matches
7});
89export async function createDatabasePagesParallel(databaseId: string, pages: []) {
10const creations = pages.map((page) =>
11notion.pages.create({
4344// delete all database rows
45export async function deleteAllDatabasePagesParallel(databaseId: string) {
46const pageIds = await notion.databases.query({
47database_id: databaseId,
59}
6061export async function getDatabaseId(databaseTitle: string) {
62// getDatabaseId(databaseTitle)
63const database = await notion.databases
66}
6768export async function getDatabaseTitle(databaseId: string) {
69// getDatabaseTitle(databaseId)
70const database = await notion.databases.retrieve({ database_id: databaseId });
73}
7475export async function getDatabaseParentPageId(databaseId: string) {
76let currentBlockId = databaseId;
7798}
99100export async function getCalloutProperties(askingFor: string) {
101const blockProperties = (askingFor != "val.town")
102? {
121}
122123export async function findChildDatabaseBlocks(rootBlockId: string, blockIdentifier: string) {
124const matchingBlocks = [];
125126async function searchBlock(blockId) {
127const res = await notion.blocks.children.list({ block_id: blockId });
128165}
166167export async function findCalloutBlocks(rootBlockId: string, blockIdentifier: string) {
168const matchingBlocks = [];
169170async function searchBlock(blockId) {
171const res = await notion.blocks.children.list({ block_id: blockId });
172200}
201202export async function getBostonTime() {
203const now = new Date();
204213}
214215export async function listChildrenChildPages(blockId: string) {
216try {
217const response = await notion.blocks.children.list({
229}
230231export async function addFavicon(data?: any) {
232const pageId = data?.id;
233// use notion if nothing if the URL property is empty
234const url = await getWebhookPropertyValue(data, "Website") || "notion.com";
235// send the URL value to the function that will get the site's favicon location
236const faviconURL = await helpers.scrapeFaviconUrl(url);
237console.log({ "Verified favicon URL": faviconURL });
242}
243244export async function setPageStatus(object: any) {
245const { data, section, step } = object;
246const pageId = data?.id;
282}
283284export async function updatePageIcon(pageId: string, faviconURL?: string) {
285try {
286const response = await notion.pages.update({
302}
303304export async function listChildren(pageId: string) {
305// get page properties
306try {
318}
319320// Helper function to get property value from webhook payload
321export async function getWebhookPropertyValue(payload: any, propertyName: any) {
322let result = null;
323// check to see if the whole payload was sent, or just the data object
357}
358359export async function getNotionPage(pageId: string) {
360// get page properties
361try {
ValTownForNotionhelpers.ts5 matches
1export async function setBlobKey(object: any) {
2const { slug, clientPageId, containerId } = object;
3const blobKey = [ // key_legend: "[subdomain]--[id of guest page]--[id of container to be reset]",
11}
1213export async function slugify(str: string) {
14// const containerTitleSlug = (await helpers.setContainerTitle(c.req.headers.get("x-container-title"))).split(" ").join("-");
15return (str.replace(/[^\w\s]|_/g, "").replace(/\s+/g, " ").trim().toLowerCase()).split(" ").join("-");
16}
1718// Function to scrape favicon URL from a website
19export async function scrapeFaviconUrl(url: string) {
20try {
21// Ensure URL has protocol
75}
7677export async function extractCamelCaseWords(str: string) {
78if (!str) return [];
79
5859// if the blob exists that maps to this callout for this user, use the id property inside it
60// otherwise call the function to find the id of the callout for this user
61// const blockId = blobject // if therre's a blob, then this isn't the first call
62// ? blobject.id // use the id in the blob to speed up subsequent calls
blog-cloneutil.tsx2 matches
1export function formatDate(dateString: string): string {
2try {
3const date = new Date(dateString);
12}
1314export function dayOfWeek(dateString: string): string {
15try {
16return new Date(dateString).toLocaleDateString("en-US", {
blog-cloneSocialLinks.tsx1 match
2import { BlueskyIcon, DiscordIcon, GitHubIcon, RSSIcon, TwitterIcon } from "./icons.tsx";
34export default function SocialLinks() {
5return (
6<div className="social-links">
blog-clonerender-markdown.ts1 match
1011// Process markdown content
12export async function processMarkdown(content: string): Promise<string> {
13const result = await unified()
14.use(remarkParse)
blog-cloneREADME.md1 match
31- **`rss.ts`**: RSS feed generation
32- **`favicon.ts`** & **`og-image.ts`**: Asset routes
33- **`/utils/`**: Utility functions for post processing, caching, etc.
34- **`/posts/`**: Markdown files for blog posts
35- **`/styles/`**: CSS styling
blog-cloneproxy.ts1 match
5const OLD_BLOG_URL = "https://val-town-blog.pages.dev/";
67export async function proxyHonoRequest(c: any) {
8const url = new URL(c.req.url);
9