From 42a81b7172c856ad611431ef7d7b468d5b1ffbfd Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 8 Aug 2023 21:01:15 -0300 Subject: content: transformContent: support [[site/media/root:path]] --- src/content/dependencies/linkPathFromMedia.js | 13 +++++++++++++ src/content/dependencies/linkPathFromRoot.js | 13 +++++++++++++ src/content/dependencies/linkPathFromSite.js | 13 +++++++++++++ src/content/dependencies/transformContent.js | 6 +++--- 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 src/content/dependencies/linkPathFromMedia.js create mode 100644 src/content/dependencies/linkPathFromRoot.js create mode 100644 src/content/dependencies/linkPathFromSite.js (limited to 'src/content') diff --git a/src/content/dependencies/linkPathFromMedia.js b/src/content/dependencies/linkPathFromMedia.js new file mode 100644 index 00000000..34a2b857 --- /dev/null +++ b/src/content/dependencies/linkPathFromMedia.js @@ -0,0 +1,13 @@ +export default { + contentDependencies: ['linkTemplate'], + + relations: (relation) => + ({link: relation('linkTemplate')}), + + data: (path) => + ({path}), + + generate: (data, relations) => + relations.link + .slot('path', ['media.path', data.path]), +}; diff --git a/src/content/dependencies/linkPathFromRoot.js b/src/content/dependencies/linkPathFromRoot.js new file mode 100644 index 00000000..dab3ac1f --- /dev/null +++ b/src/content/dependencies/linkPathFromRoot.js @@ -0,0 +1,13 @@ +export default { + contentDependencies: ['linkTemplate'], + + relations: (relation) => + ({link: relation('linkTemplate')}), + + data: (path) => + ({path}), + + generate: (data, relations) => + relations.link + .slot('path', ['shared.path', data.path]), +}; diff --git a/src/content/dependencies/linkPathFromSite.js b/src/content/dependencies/linkPathFromSite.js new file mode 100644 index 00000000..64676465 --- /dev/null +++ b/src/content/dependencies/linkPathFromSite.js @@ -0,0 +1,13 @@ +export default { + contentDependencies: ['linkTemplate'], + + relations: (relation) => + ({link: relation('linkTemplate')}), + + data: (path) => + ({path}), + + generate: (data, relations) => + relations.link + .slot('path', ['localized.path', data.path]), +}; diff --git a/src/content/dependencies/transformContent.js b/src/content/dependencies/transformContent.js index 9a135eef..625b1374 100644 --- a/src/content/dependencies/transformContent.js +++ b/src/content/dependencies/transformContent.js @@ -129,9 +129,9 @@ const linkThingRelationMap = { }; const linkValueRelationMap = { - // media: 'linkPathFromMedia', - // root: 'linkPathFromRoot', - // site: 'linkPathFromSite', + media: 'linkPathFromMedia', + root: 'linkPathFromRoot', + site: 'linkPathFromSite', }; const linkIndexRelationMap = { -- cgit 1.3.0-6-gf8a5