Skip to content

Commit

Permalink
Merge pull request #444 from significa/refactor-new-handbook-hierarchy
Browse files Browse the repository at this point in the history
refactor: new handbook hierarchy
  • Loading branch information
julietafrade97 authored Jan 24, 2025
2 parents 29071e9 + cb773f7 commit 536fe57
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 225 deletions.
130 changes: 113 additions & 17 deletions components.198185.json
Original file line number Diff line number Diff line change
Expand Up @@ -467,25 +467,28 @@
"display_name": "Author",
"description": null,
"created_at": "2023-02-15T13:03:53.849Z",
"updated_at": "2024-12-16T10:30:37.243Z",
"updated_at": "2025-01-13T08:44:47.905Z",
"id": 3442347,
"schema": {
"cover": {
"type": "asset",
"filetypes": ["images"],
"asset_folder_id": 212285,
"required": false,
"pos": 0
"pos": 0,
"id": "8dLyaE42R3GwiQWEMB9ZkQ"
},
"reading_time": {
"type": "number",
"pos": 1,
"display_name": "Reading Time (mins)"
"display_name": "Reading Time (mins)",
"id": "MiPFnbyLSjCWHlOysdIV2A"
},
"intro": {
"type": "textarea",
"required": true,
"pos": 2
"pos": 2,
"id": "ki2PS1dbQ7a2MqWpUWPImw"
},
"authors": {
"type": "options",
Expand All @@ -494,62 +497,73 @@
"required": true,
"min_options": "1",
"max_options": "4",
"pos": 3
"pos": 3,
"id": "vlcOr1lSSkynG2QKXt4YJg"
},
"services": {
"type": "options",
"source": "internal",
"datasource_slug": "services",
"pos": 4
"pos": 4,
"id": "SmiU9YHQQFmiu3YKGdcK9w"
},
"deliverables": {
"type": "options",
"source": "internal",
"datasource_slug": "deliverables",
"pos": 5
"pos": 5,
"id": "vF2l7ScsRUuUNq_nOYroKg"
},
"tech": {
"type": "options",
"display_name": "",
"source": "internal",
"datasource_slug": "tech-stack",
"pos": 6
"pos": 6,
"id": "uHMZJfCDR06MV30J7QHzKA"
},
"industry": {
"type": "options",
"source": "internal",
"datasource_slug": "industry",
"pos": 7
"pos": 7,
"id": "CssUjMEXTo6Kjnn86kwajA"
},
"seo_title": {
"type": "text",
"pos": 8
"pos": 8,
"id": "BOQalEUqQiyk1md3F5xIVA"
},
"seo_description": {
"type": "text",
"pos": 9
"pos": 9,
"id": "7NAqowg8QR2aKKFF5RhbXQ"
},
"seo_og_image": {
"type": "asset",
"filetypes": ["images"],
"asset_folder_id": 212285,
"pos": 10
"pos": 10,
"id": "aKZDfkIZSByFgTOpanjZyg"
},
"seo_canonical_url": {
"type": "text",
"pos": 11,
"description": "The default is the page URL"
"description": "The default is the page URL",
"id": "uti5hsDBSF6WaKtICvmJ3Q"
},
"structure_data_markup": {
"type": "textarea",
"description": "JSON object (https://developers.google.com/search/docs/appearance/structured-data/intro-structured-data#how-structured-data-works-in-google-search)",
"pos": 12
"pos": 12,
"id": "jlD5mft8RjCpiuV3jnrKQA"
},
"tab-9a5d9933-3840-42d8-aa24-d87e83a9eb5d": {
"display_name": "Content",
"keys": ["body"],
"pos": 13,
"type": "tab"
"type": "tab",
"id": "ml2ZMzhAQtiqJNh-g6nrXQ"
},
"tab-c1b66206-334d-4470-a996-ca9aa074e23c": {
"display_name": "SEO",
Expand All @@ -561,7 +575,8 @@
"seo_canonical_url"
],
"pos": 14,
"type": "tab"
"type": "tab",
"id": "wbZiBjNNRHCplsqaoHTiPA"
},
"body": {
"type": "richtext",
Expand Down Expand Up @@ -592,7 +607,9 @@
"redo",
"color"
],
"pos": 15
"pos": 15,
"allow_custom_attributes": true,
"id": "5ed-PQo1Sv6G4smOLUMFNg"
}
},
"image": "//a.storyblok.com/f/198185/x/f51edbf69b/screenshot-2023-03-22-at-11-49-53.png",
Expand Down Expand Up @@ -2612,6 +2629,85 @@
"content_type_asset_preview": null,
"component_group_name": "Content Types"
},
{
"name": "handbook-hierarchy-configuration",
"display_name": null,
"description": null,
"created_at": "2025-01-23T12:47:33.813Z",
"updated_at": "2025-01-23T12:57:07.248Z",
"id": 6843009,
"schema": {
"hierarchy": {
"type": "bloks",
"pos": 0,
"restrict_type": "",
"restrict_components": true,
"id": "D2dheEMnQZOfdeorIE1fWA",
"component_whitelist": ["handbook-level"]
}
},
"image": null,
"preview_field": null,
"is_root": true,
"preview_tmpl": null,
"is_nestable": false,
"all_presets": [],
"preset_id": null,
"real_name": "handbook-hierarchy-configuration",
"component_group_uuid": "a8397001-eca6-4f46-8edb-833d6924db9f",
"color": null,
"icon": null,
"internal_tags_list": [],
"internal_tag_ids": [],
"content_type_asset_preview": null,
"component_group_name": "Content Types"
},
{
"name": "handbook-level",
"display_name": null,
"description": null,
"created_at": "2025-01-23T12:50:04.973Z",
"updated_at": "2025-01-23T13:09:42.371Z",
"id": 6843171,
"schema": {
"name": {
"type": "text",
"pos": 0,
"id": "GxVX8y44QsyQju7M-cWcXQ"
},
"homepage": {
"type": "option",
"pos": 1,
"use_uuid": true,
"source": "internal_stories",
"folder_slug": "handbook/",
"id": "RnPEHft2QACPAylWLDgnrg"
},
"children": {
"type": "bloks",
"pos": 3,
"restrict_type": "",
"restrict_components": true,
"component_whitelist": ["handbook-level"],
"id": "GOEdF9mATnKRcWv5keCVMQ"
}
},
"image": null,
"preview_field": null,
"is_root": false,
"preview_tmpl": "<div> {{it.name}} </div>\n<div>\n{{@each(it.children) =&gt; val, index}}\n {{val.name}} /\n{{/each}}\n</div>",
"is_nestable": true,
"all_presets": [],
"preset_id": null,
"real_name": "handbook-level",
"component_group_uuid": "c9011224-9690-43bd-b686-e8f60ef6c7f6",
"color": null,
"icon": null,
"internal_tags_list": [],
"internal_tag_ids": [],
"content_type_asset_preview": null,
"component_group_name": "Blocks"
},
{
"name": "hero",
"display_name": null,
Expand Down
35 changes: 8 additions & 27 deletions src/components/pages/handbook/common/data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { getStoryblok } from '$lib/storyblok';
import type { HandbookStoryblok } from '$types/bloks';
import type { ISbStoryData } from '@storyblok/js';

const EXCLUSIONS = {
index: [
Expand Down Expand Up @@ -29,38 +27,21 @@ const EXCLUSIONS = {
]
} as const;

export const getHandbookEntries = async (
export const getHandbookHierarchyConfig = async (
storyblok: ReturnType<typeof getStoryblok>,
version: 'draft' | 'published' | undefined,
context: keyof typeof EXCLUSIONS = 'index'
) => {
try {
let loop = true;
let page = 1;
const results: ISbStoryData<HandbookStoryblok>[] = [];
const res = await storyblok.get('cdn/stories/configuration/handbook-hierarchy-config', {
version,
excluding_fields: EXCLUSIONS[context].join(','),
resolve_relations: 'handbook-level.homepage,handbook-level.children'
});

do {
const res = await storyblok.get('cdn/stories', {
starts_with: 'handbook',
cv: Date.now(),
version,
excluding_fields: EXCLUSIONS[context].join(','),
page,
per_page: 100
});

results.push(...res.data.stories);

if (results.length >= res.total) {
loop = false;
}

page++;
} while (loop);

return results;
return res.data.story;
} catch (err) {
console.error('Failed to fetch Handbook entries', err);
console.error('Failed to fetch Handbook Hierarchy Config', err);
throw err;
}
};
5 changes: 0 additions & 5 deletions src/components/pages/handbook/common/utils.ts

This file was deleted.

63 changes: 0 additions & 63 deletions src/components/pages/handbook/handbook-page/utils.ts

This file was deleted.

Loading

0 comments on commit 536fe57

Please sign in to comment.