Adding og images to VitePress - yaml-front-matter

I've seen that in the VitePress .md files you can add meta description and keywords like this,
head:
- - meta
- name: description
content: my custom description
But I can't seem to figure out how to add og:title or og:image, it seems that the : throws an error when compiling.

Refer:
YAML: Do I need quotes for strings in YAML?
How to escape indicator characters (i.e. : or - ) in YAML
So you basically need to do:
head:
- - meta
- name: 'og:title'
content: Foo Bar
Moreover, VitePress supports setting the frontmatter in JSON too. So this should also work:
{ "head": [["meta", { "name": "og:title", "content": "Foo Bar" }]] }

Related

Questions about fileContentReplaceItemConfig search pattern using groovy

I have the following groovy instructions applied on Jenkins.
stage('Replace content') {
steps {
contentReplace(
configs: [
fileContentReplaceConfig(
configs: [
fileContentReplaceItemConfig(
search: ".appName.*",
replace: ''
)
],
fileEncoding: 'UTF-8',
filePath: 'register.scala')
])
}
}
What is the meaning of the pattern ".appName.*"? Every line which contains the word 'appName', the entire line will be removed in register.scala file?
Content Replace plugin
The Content Replace plugin site states the following
Regex expression for search. e.g. (Version=)([0-9]+.[0-9]+.[0-9]+)
It is a regular expression. It's not necessarily the entire line. Here is an example string: asdfasdfappNameasdf this would be replaced with asdfasd. So it will replace appName, a character before appName, and everything after appName
Below is a pattern matching example from regexr

$formatNumber outputs NaN when used in table array

I'm applying number formatting to a PDF document, which works fine in a 'parent' record in the JSON data, but fails when used inside a table. How can I get the $formatNumber expression to work inside an array of data?
The data is being merged into an invoice document, and in one of the columns of the "Invoice Line Items" I'd like to format the number with the expression $formatNumber, '#,###.00'.
Here is the merge syntax in my word document:
This formatting works fine for the parent data:
{{ $formatNumber(QuoteLineItems.totalSize, '#,###.00') }}
This formatting fails when used inside a table (the output in the PDF si "NaN")
{{ $formatNumber(QuoteLineItems.records.AmountNet, '#,###.00') }}
Image: Comparison of Success vs Failure syntax
Image: PDF Output contains NaN in table
here is the sample input data I am using inside the word plugin document tagger:
{
"QuoteLineItems":
{
"records":
[
{
"AmountGross": 47897,
"AmountNet": 44556,
"Name": "Sample Charges"
},
{
"AmountGross": 4968,
"AmountNet": 4621,
"Name": "Sample 2 Charges"
}
],
"done": true,
"totalSize": 2
},
"Name": "Sample Invoice"
}
Sorry for the delay in answering this. This is a known bug (I'm going to check on the status). For now I suggest doing your number format in your code before sending it to the API. If that doesn't make sense, let me know and I'll clarify.

Is "Comment" a protected word in the Open API 3.0 spec or Swagger Editor?

I'm currently working on an API spec using the Swagger Editor (v3.1.9) and the Open API 3 specification.
I'm getting some peculiar behavior specifically for a Schema component I have named Comment
Comment:
description: "A comment on an asset or submission"
allOf:
- $ref: "#/components/schemas/Message"
type: object
properties:
parent:
oneOf:
- $ref: "#/components/schemas/Asset"
- $ref: "#/components/schemas/Submission"
In the UI, it renders as (with none of the inheritance from Message)
Comment {
description: A comment on an asset or submission
parent {
oneOf -> {
}
v {
}
}
}
However, if I rename it to anything else, say Commentary it will render fully (with inheritance from Message):
Commentary{
description: A comment on an asset or submission
id string($uuid)
example: f1907c82-2c5f-4f60-8cd9-12647d411822
author User{...}
body string
example: Lorem ipsum dolor sit amet
message_type string
example: DiscussionPost
parent {
oneOf -> Asset{...}
Submission{...}
}
}
The only thing I can think of is that there is somehow a reserved word for Comment in either or both of the Open API spec or Swagger Editor. The main thing I want to know is if this is indeed a bug, or if I should be avoiding using this name (and if that's the case, if there are any others I should avoid)
No, Comment is not a reserved word. Your schema is correct.
The schema rendering issue seems to have been a bug that is now fixed. Your schema is rendered correctly in the latest Swagger Editor.

How can I get the FULL list of slack emoji through API?

I am using the slack API to get the full list of emoji, so that when I get a message, I will just replace :squirrel: with the icon.
The method https://slack.com/api/emoji.list works like a charm, but returns 30 icons only. I think this is correct since in the documentation page (https://api.slack.com/methods/emoji.list) they say:
This method lists the custom emoji for a team.
Fair enough, but how can I get the full list of the associations icon-name / icon URL ?
I finally managed to get all the icons and to use them and I post here the solution for anyone that would like to use do similar:
First of all, I got the Slack Custom Emoji through this slack URL
Since at step 1 we get only Custom Emojis, it is useful to know that slack uses standard emoji defined in unicode characters, mapped through custom handles like :smiley: or :horse:. The good thing is that we can find, linked through slack page a link to a JSON object with all the emoji mappings. This file is HUGE, but has everything we need.
In the file you'll find an array of javascript object like the one below:
{
"name":"SMILING FACE WITH OPEN MOUTH",
"unified":"1F603",
"variations":[],
"docomo":"E6F0",
"au":"E471",
"softbank":"E057",
"google":"FE330",
"image":"1f603.png",
"sheet_x":26,
"sheet_y":18,"
short_name":"smiley",
"short_names":["smiley"],
"text":":)",
"texts":["=)","=-)"],
"category":"People",
"sort_order":5,
"has_img_apple":true,
"has_img_google":true,
"has_img_twitter":true,
"has_img_emojione":true
}
I used the following information:
shortnames are the names that are used in slack (you'll need to turn smiley into :smiley: )
unified is the unicode character to use (to use it directly in an HTML page you'll need to add &#x so in this case you'll have to use 😃 which is rendered 😃
Using this information you will be able to create a slack-to-html function to decode emojis and display them wherever you want
Not entirely sure if this is what you are looking for, but if it's just about mapping images to slack-style names, this is a pretty good library:
https://github.com/iamcal/emoji-data
So, building on the example in their README:
The emoji with the Slack style short name point_uphas the hex value 261d, and can thus be found here: https://github.com/iamcal/emoji-data/blob/master/img-apple-160/261d.png
(Apple, because the default slack emoji are the apple emoji)
Just extending on #Luca's awesome solution, I've created a shortnames => html unicode javascript dictionary...
Download: Slack emoticons to unicode html mapping.
Generated - 17th August 2018 from the source https://raw.githubusercontent.com/iamcal/emoji-data/master/emoji.json
Example:
{
"+1": "👍",
"-1": "👎",
"100": "💯",
"1234": "🔢",
"8ball": "🎱",
"ab": "🆎",
"abc": "🔤",
"abcd": "🔡",
"accept": "🉑",
...
"zebra_face": "🦓",
"zipper_mouth_face": "🤐",
"zombie": "🧟",
"zzz": "💤"
}
Which becomes...
{ "+1": "👍", "-1": "👎", "100": "💯",
"1234": "🔢", "8ball": "🎱", "ab": "🆎",
"abc": "🔤", "abcd": "🔡", "accept": "🉑",
... "zebra_face": "🦓", "zipper_mouth_face": "🤐",
"zombie": "🧟", "zzz": "💤" }
As far as I know, there is no API endpoint or comprehensive list of supported emoji/keywords available. I was able to grab the full set (including custom emoji for the workspace) by inspecting the Slack emoji picker using React Developer Tools (Chrome extension).
Here's an example (JSON):
...
{
"name": "beers",
"unicode": "1f37b",
"id": "E1f37b",
"keywords": ["bar", "beer", "clink", "drink", "mug", "ale", "food"]
},
{
"name": "baby_bottle",
"unicode": "1f37c",
"id": "E1f37c",
"keywords": ["baby", "bottle", "drink", "milk", "infant"]
},
{
"name": "knife_fork_plate",
"unicode": "1f37d-fe0f",
"id": "E1f37d-fe0f",
"keywords": ["cooking", "fork", "knife", "plate"]
},
{
"name": "champagne",
"unicode": "1f37e",
"id": "E1f37e",
"keywords": ["bar", "bottle", "cork", "drink", "popping"]
},
{ "name": "popcorn", "unicode": "1f37f", "id": "E1f37f", "keywords": [] },
...
Full dump (as of 12/20/2020, excluding custom emoji): https://gist.github.com/impressiver/87b5b9682d935efba8936898fbfe1919
Since it seemed impossible to find a complete and up-to-date source for these emoji names I came up with this browser console script. Just let it run in Slack and when it finishes it will download a full emoji.json. At time of writing it contains 2485 entries.
https://gist.github.com/8461e125072c2806301403a4e1eca891
This looks like this:
{
"+1": "https://a.slack-edge.com/production-standard-emoji-assets/13.0/google-medium/1f44d#2x.png",
"+1::skin-tone-2": "https://a.slack-edge.com/production-standard-emoji-assets/13.0/google-medium/1f44d-1f3fb#2x.png",
"+1::skin-tone-3": "https://a.slack-edge.com/production-standard-emoji-assets/13.0/google-medium/1f44d-1f3fc#2x.png",
"+1::skin-tone-4": "https://a.slack-edge.com/production-standard-emoji-assets/13.0/google-medium/1f44d-1f3fd#2x.png",
If you want the actual emoji instead of the image you can parse that out of the image file name, e.g. 1f44d-1f3fd#2x.png is "\u1f44d\u1f3fd".

XML Tags using Builder

I am currently building an XML export for a Real Estate app. using the Builder gem in Rails. And I am looking for a way to do the following:
<commercialRent>
"commercialRent figure"
<range>
...
</range>
</commercialRent>
I can't seem to find a way to implement the "Text Goes Here" part
My code:
b.commercialRent(period: "annual", plusOutgoings: self.plus_outgoings) {
self.rent_price;
b.range {
b.min(self.rent_psm_pa_min);
b.max(self.rent_psm_pa_max)
};
};
Returns:
<commercialRent period="annual" plusOutgoings="no">
<rentPerSquareMeter>
<range>
<min>1000</min>
<max>10000</max>
</range>
</rentPerSquareMeter>
</commercialRent>
Everything prints fine, except the self.rent_price is missing.
I can't figure it out.
You use the text! method to produce a text node:
- (Object) text!(text)
Append text to the output target. Escape any markup. May be used within the markup brackets as:
builder.p { |b| b.br; b.text! "HI" } #=> <p><br/>HI</p>
So something like this should do the trick:
b.commercialRent(period: "annual", plusOutgoings: self.plus_outgoings) do
b.text! self.rent_price
#...
end

Resources