-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #340 from Shinsina/podcast-adjustments
Podcast Social Link Adjustments
- Loading branch information
Showing
6 changed files
with
83 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { readFileSync } from 'fs'; | ||
import { resolve } from 'path'; | ||
import { get } from "@parameter1/base-cms-object-path"; | ||
import createClasses from "@parameter1/base-cms-marko-web-icons/utils/create-classes"; | ||
|
||
$ const getProvider = ({ provider, label }) => { | ||
let formatted = provider ? `${provider}`.toLowerCase() : ''; | ||
if (formatted === 'other' && label) formatted = `${label}`.toLowerCase(); | ||
return formatted; | ||
}; | ||
$ const load = () => { | ||
try { | ||
const file = resolve(__dirname, `../svg/${input.provider}.svg`); | ||
return readFileSync(file, 'utf8').toString(); | ||
} catch (e) { | ||
return null; | ||
} | ||
}; | ||
$ const blockName = input.blockName || 'marko-web-icon'; | ||
$ const className = input.className || "social-icon-link"; | ||
$ const provider = get(input, "provider", ""); | ||
$ const label = get(input, "label", ""); | ||
|
||
$ const formatted = getProvider({ provider, label }); | ||
$ const name = label || provider; | ||
$ const title = name ? `Visit us on ${name.charAt(0).toUpperCase()}${name.slice(1)}` : null; | ||
$ const svg = load(); | ||
|
||
$ const classNames = createClasses({ | ||
iconName: name, | ||
blockName, | ||
modifiers: input.modifiers, | ||
}); | ||
|
||
<if(formatted && input.href && svg)> | ||
$ const tag = input.tag || 'span'; | ||
<marko-web-link | ||
class=className | ||
href=input.href | ||
target=input.target | ||
title=title | ||
attrs=input.attrs | ||
> | ||
<${tag} ...input.attrs class=classNames>$!{svg}</> | ||
</marko-web-link> | ||
</if> | ||
<else> | ||
<theme-social-icon-link | ||
...input | ||
/> | ||
</else> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,3 +80,8 @@ | |
.watch-latest-rail { | ||
text-align: center; | ||
} | ||
|
||
.marko-web-icon--podcast-icon svg { | ||
height: 5rem; | ||
width: 5rem; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters