Skip to content

Commit

Permalink
Add noindex option
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Jul 24, 2024
1 parent 0f9cc5b commit 81ded9c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/langs/json/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,7 @@
"source": "Source",
"published_url": "Published URL",
"related_article": "Related article URL",
"noindex": "Hide from search engines and DocumentCloud search",
"access": {
"title": "Access",
"description": "Changing the access setting will reprocess your document."
Expand Down
5 changes: 5 additions & 0 deletions src/lib/components/forms/Edit.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Usually this will be rendered inside a modal, but it doesn't have to be.
import AccessLevel from "../inputs/AccessLevel.svelte";
import Field from "../inputs/Field.svelte";
import Switch from "../inputs/Switch.svelte";
import Text from "../inputs/Text.svelte";
import TextArea from "../inputs/TextArea.svelte";
Expand Down Expand Up @@ -62,6 +63,10 @@ Usually this will be rendered inside a modal, but it doesn't have to be.

<hr class="divider" />

<Field title={$_("edit.fields.noindex")} inline>
<Switch name="noindex" checked={document.noindex} />
</Field>

<Field
title={$_("edit.fields.access.title")}
description={$_("edit.fields.access.description")}
Expand Down
11 changes: 3 additions & 8 deletions src/routes/documents/[id]-[slug]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,10 @@ export const actions = {
const form = await request.formData();
const { id } = params;

const update: Partial<Document> = {};
const update: Partial<Document> = Object.fromEntries(form);

// set any fields that aren't blank
Array.from(form).reduce((m, [k, v]) => {
if (v) {
m[k] = v;
}
return m;
}, update);
// noindex is a boolean so needs special treatment
update.noindex = form.get("noindex") === "checked";

try {
const document = await edit(id, update, csrf_token, fetch);
Expand Down

0 comments on commit 81ded9c

Please sign in to comment.