Skip to content

Commit

Permalink
Support x-client in note posting script
Browse files Browse the repository at this point in the history
  • Loading branch information
brookback committed Dec 7, 2023
1 parent 81ec725 commit 5ace3da
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion functions/post-note.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,21 @@ const handle = async ({ request, env }) => {
const branch = isLocal(url) ? 'dev' : 'main';
const date = formatDate(d);
const fileDate = formatDate(d, true);
const client = request.headers.get('x-client');

const location = (() => {
switch (client) {
case 'macos-shortcut': return 'My Mac shortcut';
case 'ios-shortcut': return 'My iOS shortcut';
default:
console.warn(`Unknown client posting: ${client}`);
return 'My script';
}
})();

const content = `---
date: ${date}
location: My iOS shortcut
location: ${location}
---
${body}\n
`;
Expand Down

0 comments on commit 5ace3da

Please sign in to comment.